Solved

Copy non-existing file from server machine

Posted on 2004-09-01
6
188 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 39 total points
ID: 11960371
0
 
LVL 92

Assisted Solution

by:objects
objects earned 37 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 37 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 37 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresSpecial  challenge 13 42
powerN  challenge 3 49
wordlen challenge 3 47
eclipse compiler vs Installed JREs option 3 42
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now