• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need someones help very quickly with File copying, PLEASE!!

 
Nizan Horsefield
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have successfully created a client program that checks for the exisitence of web server log files. If they do or don't exist it sends a message to a server program (suing sockets). What I now need to do is take the size of the file send that to the server, then copy the actual file from the client to the server via TCP. Once at the server the server program will check the size before and after for error checking. I have written this Java program to replace the current DOS and Perl scripts.
What data stream do I use? Do I need a PipedInput connected to a PipedOutput? PLease help as I need to get this finished this week.
To clarify - I need to be able to do a file copy from a client to a server using sockets. I can't use a server application to connect to a remote machine as NetBios is disabled for secuity.
Please Help!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, copying files has been covered a number of times recently. Check out a recent discussion here. The copyStream method I gave can be easily modified to count the number of bytes read as well. (Annoyingly, there doesn't seem to be a simple method for getting the size of a file in Java.) Since you're using sockets, you'll need to use the getInputStream() and getOutputStream() methods of Socket on the server and client respectively. I don't see any need for PipedInputStream or PipedOutputStream, but you could probably use these too.
 
Nizan Horsefield
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sheriff
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correction - the File class does have a method to find the size of a file - the length() method. Guess I didn't look closely enough...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!