Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copy non-existing file from server machine

Posted on 2004-09-01
6
Medium Priority
?
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

721 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