Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read File on Server Side

Status
Not open for further replies.

joek71

Programmer
May 4, 1999
6
US
I am trying to connect to a local area server and read a file from that server, but I seem not to be able to read it, I think I am connecting but I dont know.
Can someone please provide an example of how to connect the right way and read a file.

Thank You
 
If the "local area server" means a local web server:

import java.io.*;
import java.net.*;

public class HtmlReader {
public static void main(String[] args) throws MalformedURLException,
IOException {
String s;
URL urlTxt=new URL(" InputStream in=urlTxt.openStream();
DataInputStream din=new DataInputStream(in);
while (true) {
s=din.readLine();
if (s==null) break;
System.out.println(s);
}
in.close();
}
}

Good luck.
Bye, Otto.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top