2 private String hostname;
5 private StringBuffer response;
7 public Query(String hostname, String path) {
8 this.hostname=hostname;
10 response=new StringBuffer();
13 public String getHostName() {
17 public String getPath() {
21 public void outputFile() {
22 StringBuffer sb=new StringBuffer(hostname);
24 FileOutputStream fos=new FileOutputStream(sb.toString().replace('/','#'));
25 fos.write(response.toString().getBytes());
29 public String makewebcanonical(String page) {
30 StringBuffer b=new StringBuffer(getHostName(page));
32 b.append(getPathName(page));
36 public String getHostName(String page) {
37 String http=new String("http://");
38 if (page.indexOf(http)==-1) {
41 int beginindex=page.indexOf(http)+http.length();
42 int endindex=page.indexOf('/',beginindex+1);
43 if ((beginindex==-1)) {
44 System.printString("ERROR");
47 endindex=page.length();
48 return page.subString(beginindex, endindex);
52 public String getPathName(String page) {
53 String http=new String("http://");
54 if (page.indexOf(http)==-1) {
55 String path=getPath();
56 int lastindex=path.lastindexOf('/');
60 StringBuffer sb=new StringBuffer(path.subString(0,lastindex+1));
64 int beginindex=page.indexOf(http)+http.length();
65 int nextindex=page.indexOf('/',beginindex+1);
66 if ((beginindex==-1)||(nextindex==-1))
67 return new String("index.html");
68 return page.subString(nextindex+1, page.length());