Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read from file from a remote machine

 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you passing the domain name as well? Often you need to specify the user name as domain\user.
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic