public void amethod(){
try{
//From file (This is where I need to make the changes)
//In order to connect to a Server file
FileInputStream fis = new FileInputStream("Out.txt");
//DataInputStream allows you to read
DataInputStream dis = new DataInputStream(fis);
//Create file
FileOutputStream fos = new FileOutputStream("Out1.txt");
//DataOutputStream allows you to write
DataOutputStream dos = new DataOutputStream(fos);
while(true){
//This line reads and writes to a file
dos.writeShort(dis.readShort());
}
}catch(IOException ioe) {}
}
Discussions
EJB programming & troubleshooting: Need to make changes in my code to connect to a server file
-
Need to make changes in my code to connect to a server file (3 messages)
- Posted by: Web Master
- Posted on: August 22 2001 10:06 EDT
Threaded Messages (3)
- Need to make changes in my code to connect to a server file by Praveen Balakrishnan on August 22 2001 19:21 EDT
- Need to make changes in my code to connect to a server file by Web Master on August 23 2001 11:03 EDT
- Need to make changes in my code to connect to a server file by Praveen Balakrishnan on August 23 2001 11:11 EDT
- Need to make changes in my code to connect to a server file by Web Master on August 23 2001 11:03 EDT
-
Need to make changes in my code to connect to a server file[ Go to top ]
- Posted by: Praveen Balakrishnan
- Posted on: August 22 2001 19:21 EDT
- in response to Web Master
What type of server. if it is a http server.
you can use java.net.URL and URLConnection and get the InputStream from the connection..
-
Need to make changes in my code to connect to a server file[ Go to top ]
- Posted by: Web Master
- Posted on: August 23 2001 11:03 EDT
- in response to Praveen Balakrishnan
Thanks for the hint. Could you give me more of an idea of how I can go about it. Never done this sort of stuffs. -
Need to make changes in my code to connect to a server file[ Go to top ]
- Posted by: Praveen Balakrishnan
- Posted on: August 23 2001 11:11 EDT
- in response to Web Master
URL anyURL = new URL("http://localhost/anyfile.ext");
BufferedInputStream buf = new BufferedInputStream(anyURL.openStream());