This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

copying a file  RSS feed

 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i have a file which i need to copy to another system through jsp.

i have the following code.

*************
String dst="http://<hostname>/picture/"+libname+"/"+picname+".jpg";
System.out.println(dst);
InputStream in = new FileInputStream(location);
OutputStream out1 = new FileOutputStream(dst);

// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out1.write(buf, 0, len);
}
in.close();
out1.close();

*************

but, i get an error message stating that the resource cannot be found. the system fails to recognize the two '//'s given and takes only one irrespective of the number of /'s i give.

can someone help me on this?
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at these classes

java.net.HttpURLConnection
java.net.URLConnection

I think it will be better to use them instead of java.io.* package.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the I/O forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!