A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Java in General
Author
Writing files on remote server
Raj Puri
Ranch Hand
Joined: Apr 24, 2003
Posts: 189
posted
May 27, 2005 15:51:00
0
I have follwoing Java program. Seems it does work but does not copy any file. This should copy from my hard drive to a URL. Any idea?
import java.io.*;
import java.net.*;
public class loadimage {
public static void main(
String
[] args) {
try
{
URL u = new URL("http://localhost:9050/jsp-examples");
URLConnection
uc = u.openConnection();
// uc.connect();
uc.setDoOutput(true);
OutputStream
fout = uc.getOutputStream();
FileInputStream
fin = new
FileInputStream
("c:/xxx");
System.out.println("aaa");
byte[] buffer = new byte[256];
while(true)
{
int bytesRead = fin.read(buffer);
System.out.println(bytesRead);
if (bytesRead == -1) break;
fout.write(buffer, 0, bytesRead);
System.out.println("qaaa");
}
fin.close();
fout.close();
}
catch (
IOException
ioe) {System.err.println(ioe.toString()); }
}
}
I agree. Here's the link:
http://aspose.com/file-tools
subject: Writing files on remote server
Similar Threads
Uploading Image from Java Desktop App to Server
Urgent !
Sending a file over socket
File upload
Send a file across the network
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter