Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Copying a file from a directory of remote machine

Posted on 2005-05-17
17
Medium Priority
?
163 Views
Last Modified: 2010-03-31
I want to copy a file from a remote machine. On the remote machine the required file should be browsed as It is on my local machine. When I copy the file on remote then I want to paste it on my local machine.
Please send me the java code , how it can be done?
0
Comment
Question by:AfzalHaidry
  • 9
  • 6
15 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 14018071
If it's on a LAN you can get the file thus

File f = new File("\\\\machine_name\\share_name\\filename");

Not copy in the usual way
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14018076
'Not copy in the usual way' = 'Now copy in the usual way'
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14018080
FTP or via a directory share...

Or a website that allows you to view all files on the hard disk (though this would be very dangerous)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 14018082
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14018092
>>  If it's on a LAN you can get the file thus

If it's a Windows machine on a LAN surely? ;-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14018097
I mean of course...

"If the client machine is a Windows machine on a LAN surely? ;-)"

hehe
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14018104
Yes. The same technique (different Strings though) can be used on Unix though
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14018209
>>  Yes. The same technique (different Strings though) can be used on Unix though

They can?

Ooooh....do you know what strings would work?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14018246
File f = new File("machine_name:/x/y/z/filename");

should do it i think if the network is in your favour
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14018256
(Let me know if you try it ;-))
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14018328
Doesn't work here... :-(

Might be our network config though...  I have to use ssh and scp to go between machines...  Or mount them locally...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14018402
Might be worth trying to get this protocol handler - you never know your luck ;-)

URL scp = new URL("scp://machinename/x/y/z/filename");
0
 
LVL 35

Expert Comment

by:TimYates
ID: 14229990
Fair enough :-)

btw cehj, scp: isn't a valid protocol :-(

I guess our network is locked down against this sort of thing ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14255343
>>btw cehj, scp: isn't a valid protocol :-(

Could be that a special protocol handler would have to be installed

>>I guess our network is locked down against this sort of thing ;-)

If you can scp at the command line, given all systems go on the above, Java should probably be able to do it
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14255387
>>given all systems go on the above

(Which *should* be the case if you install an ssh API for java)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

572 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