aspose file tools*
The moose likes I/O and Streams and the fly likes how to read from file from a remote machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "how to read from file from a remote machine" Watch "how to read from file from a remote machine" New topic
Author

how to read from file from a remote machine

Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
Hello, i have had a look at similar questions on here, but cannot find a solution

How do I read from a remote windows machine that requires password and username. Please note the C drive is shared. It requires login, I don't want to use ftp, just java io.

- is not working, it requires login

I am trying


But it is not working

I have also tried


But I get java.lang.IllegalArgumentException

URI has an authority component
please help
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
A Windows JDK should be able to access remote SMB shares given the right file syntax.

If the client is something else (like some kind of Unix-ish box) then you'd need to use the jCIFS library (the API of which closely resembles File, FileInputStream and FileOutputStream, so it's easy to use).
Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
@Lester

Thanks the quick reponse. The remote machine is a windows 2003 server. With using the username and password, I get

"Logon failure: unknown user name or bad password"

What is the correct syntax for passing the password and username with the server & files details?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

Are you passing the domain name as well? Often you need to specify the user name as domain\user.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sege Stephen
Ranch Hand

Joined: Oct 06, 2007
Posts: 51
@Rob, I am not passing the domain. Although I saw some examples on the internet where the domain are being passed.

I had solved this problem by mounting the drive. For anyone else wanting to know the solution, I mounted the drive by assigning it an unused drive. I used the process command -
net use F:/servername/shared \user username password
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read from file from a remote machine