00001 package cz.vutbr.fit.dudka.SGVis.Lookup;
00002
00003 import java.io.BufferedReader;
00004 import java.io.IOException;
00005 import java.io.InputStreamReader;
00006 import java.net.URL;
00007 import java.net.URLConnection;
00008
00009
00014 public class SimpleDownloader {
00015 private int maxLength = 1 << 20;
00016
00023 public String download(URL url) throws IOException {
00024
00025 URLConnection conn = url.openConnection();
00026
00027
00028 BufferedReader reader =
00029 new BufferedReader(new InputStreamReader(conn.getInputStream()));
00030
00031
00032 StringBuffer buff = new StringBuffer();
00033 String inputLine;
00034 while (
00035 buff.length()<maxLength &&
00036 null!= (inputLine = reader.readLine()))
00037 buff.append(inputLine);
00038
00039
00040 reader.close();
00041
00042
00043 if (buff.length()>maxLength)
00044 buff.setLength(maxLength);
00045
00046
00047 return buff.toString();
00048 }
00052 public int getMaxLength() {
00053 return maxLength;
00054 }
00058 public void setMaxLength(int maxLength) {
00059 this.maxLength = maxLength;
00060 }
00061 }