Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copy non-existing file from server machine

Posted on 2004-09-01
6
Medium Priority
?
239 Views
Last Modified: 2010-03-31
E.g. I have 2 same folder at client and server called "backup", now i want to copy all the files from server to client (those files are not exist in client). The file should include sub directory and sub directory's files.

The copy program should locate at client machine.

thanks
0
Comment
Question by:hawkly
6 Comments
 
LVL 6

Accepted Solution

by:
expertmb earned 156 total points
ID: 11960371
0
 
LVL 92

Assisted Solution

by:objects
objects earned 148 total points
ID: 11960955
use the following to copy from one stream to another (in your case you file stream):

public static copyStream(InputStream in, OutputStream out)
{
   int n = 0;
   byte[] buf = new byte[1024];
   while (-1!=(n=in.read(buf)))
   {
      out.write(buf, 0, n);
   }
   out.close();
   in.close();
}

How will the client be accessing the files on the server?
0
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 148 total points
ID: 11961180
> How will the client be accessing the files on the server?

This is the most important question...

You can do this via FTP, RMI or something like a servlet...

Each solution requires a different server setup, but without them you cannot just copy files off one machine to another
0
 
LVL 11

Assisted Solution

by:cjjclifford
cjjclifford earned 148 total points
ID: 11961571
have a look into RSYNC (http://samba.anu.edu.au/rsync/), it is for synchronizing the same data onto multiple machines, this might work for your approach... otherwise use FTP(various Java FTP libraries available that allow browsing directories) to get a list of remote files, and fetch those that do not exist locally (also take care of changes to remote files, i.e. check timestamp or remote files and keep track of when local files were synchronized!)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question