C
cool2005
I tried to fatch a wab page in java as following
public static String downloadWWWPage(String pageAddr) throws
IOException {
....
URL url = new URL(pageAddr);
String websiteAddress = url.getHost();
String file = url.getFile();
....
Socket clientSocket = new Socket(websiteAddress, 80);
System.out.println("Socket opened to " + websiteAddress + "\n");
// creating a BufferReader object using the input stream reader
// this will read the content send by the webserver
BufferedReader inFromServer = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
// Need to create a output stream writer
// that will talk to the webserver of the website
OutputStreamWriter outWriter = new OutputStreamWriter(clientSocket
.getOutputStream());
// make the GET call to the webserver with the desired url or the
// file name
// which you intent to get, also mention the protocol type, which is
// HTTP/1.0
// This call will trigger the webserver to throw this page, which
// will be read
// by the input stream
// making a get call to the file
outWriter.write("GET " + file + " HTTP/1.0\r\n\n");
===============================
The problem is that when varible "file" above contain a space charater
(even I encoded the space to %20 or  
I got 404 but the same url
worked in the address field of a browser.
Is there any way to get around?
thanks
mark
public static String downloadWWWPage(String pageAddr) throws
IOException {
....
URL url = new URL(pageAddr);
String websiteAddress = url.getHost();
String file = url.getFile();
....
Socket clientSocket = new Socket(websiteAddress, 80);
System.out.println("Socket opened to " + websiteAddress + "\n");
// creating a BufferReader object using the input stream reader
// this will read the content send by the webserver
BufferedReader inFromServer = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
// Need to create a output stream writer
// that will talk to the webserver of the website
OutputStreamWriter outWriter = new OutputStreamWriter(clientSocket
.getOutputStream());
// make the GET call to the webserver with the desired url or the
// file name
// which you intent to get, also mention the protocol type, which is
// HTTP/1.0
// This call will trigger the webserver to throw this page, which
// will be read
// by the input stream
// making a get call to the file
outWriter.write("GET " + file + " HTTP/1.0\r\n\n");
===============================
The problem is that when varible "file" above contain a space charater
(even I encoded the space to %20 or  
worked in the address field of a browser.
Is there any way to get around?
thanks
mark