Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Reading a file from another machine on the network

Reply
Thread Tools

Reading a file from another machine on the network

 
 
mineshdesai@gmail.com
Guest
Posts: n/a
 
      03-14-2007

Hello,

I have a requirement in which i want to read a file from another
machine in the network. And also the machine is password protected.

Can any one help me out in this.

I tried doing it in following way,

URI uri = URI.create("file://9.182.198.145/shared");

File file = new File(uri);

As i excute this code i get an exception as:
java.lang.IllegalArgumentException: URI has an authority component

Can any one help me out in this.

Thanks in Advance

 
Reply With Quote
 
 
 
 
Michael Rauscher
Guest
Posts: n/a
 
      03-14-2007
schrieb:
> Hello,
>
> I have a requirement in which i want to read a file from another
> machine in the network. And also the machine is password protected.


Which protocol?

>
> Can any one help me out in this.
>
> I tried doing it in following way,
>
> URI uri = URI.create("file://9.182.198.145/shared");
>
> File file = new File(uri);
>
> As i excute this code i get an exception as:
> java.lang.IllegalArgumentException: URI has an authority component


Seems like the above is treated as UNC name which can't be used accross
platforms. E. g. Linux would look for a file 'shared' in directory
'9.182.198.145'.

Under windows you might want to try
"file://usernameassword@9.182.198.145/shared"

but perhaps it's easier to mount the share via

net use X: \\9.182.198.145\Shared <password> /user:<username>

and then access the file via X:

Bye
Michael
 
Reply With Quote
 
 
 
 
mineshdesai@gmail.com
Guest
Posts: n/a
 
      03-14-2007
On Mar 14, 4:14 pm, Michael Rauscher <michlm...@gmx.de> wrote:
> mineshde...@gmail.com schrieb:
>
> > Hello,

>
> > I have a requirement in which i want to read a file from another
> > machine in the network. And also the machine is password protected.

>
> Which protocol?
>
>
>
> > Can any one help me out in this.

>
> > I tried doing it in following way,

>
> > URI uri = URI.create("file://9.182.198.145/shared");

>
> > File file = new File(uri);

>
> > As i excute this code i get an exception as:
> > java.lang.IllegalArgumentException: URI has an authority component

>
> Seems like the above is treated as UNC name which can't be used accross
> platforms. E. g. Linux would look for a file 'shared' in directory
> '9.182.198.145'.
>
> Under windows you might want to try
> "file://usernameassw...@9.182.198.145/shared"
>
> but perhaps it's easier to mount the share via
>
> net use X: \\9.182.198.145\Shared <password> /user:<username>
>
> and then access the file via X:
>
> Bye
> Michael


Michael Thanks for reply,

I will explain you the requirement,

I have few machines on the network, i want to access a file under
"shared" folder on the machine with i.p address as 9.182.198.145

and all the systems have windows OS.

One more thing i tried with following code and i got the same
exception

URI uri = URI.create("file://usernameassword@9.182.198.145/shared");

File file = new File(uri);


can you please help me out in this.

Thanks

 
Reply With Quote
 
Michael Rauscher
Guest
Posts: n/a
 
      03-14-2007
schrieb:
> On Mar 14, 4:14 pm, Michael Rauscher <michlm...@gmx.de> wrote:
>> mineshde...@gmail.com schrieb:
>>
>>> Hello,
>>> I have a requirement in which i want to read a file from another
>>> machine in the network. And also the machine is password protected.

>> Which protocol?
>>
>>
>>
>>> Can any one help me out in this.
>>> I tried doing it in following way,
>>> URI uri = URI.create("file://9.182.198.145/shared");
>>> File file = new File(uri);
>>> As i excute this code i get an exception as:
>>> java.lang.IllegalArgumentException: URI has an authority component

>> Seems like the above is treated as UNC name which can't be used accross
>> platforms. E. g. Linux would look for a file 'shared' in directory
>> '9.182.198.145'.
>>
>> Under windows you might want to try
>> "file://usernameassw...@9.182.198.145/shared"
>>
>> but perhaps it's easier to mount the share via
>>
>> net use X: \\9.182.198.145\Shared <password> /user:<username>
>>
>> and then access the file via X:
>>
>> Bye
>> Michael

>
> Michael Thanks for reply,
>
> I will explain you the requirement,
>
> I have few machines on the network, i want to access a file under
> "shared" folder on the machine with i.p address as 9.182.198.145
>
> and all the systems have windows OS.
>
> One more thing i tried with following code and i got the same
> exception


Sorry, I was wrong.

Either you've got access to the Share, then you can simply use the UNC
name (\\9.182.198.145\Shared). Otherwise I thinkg you'd have to map the
Share to a drive letter or to have a look at http://jcifs.samba.org

Bye
Michael
 
Reply With Quote
 
mineshdesai@gmail.com
Guest
Posts: n/a
 
      03-14-2007
On Mar 14, 5:53 pm, Michael Rauscher <michlm...@gmx.de> wrote:
> mineshde...@gmail.com schrieb:
>
>
>
>
>
> > On Mar 14, 4:14 pm, Michael Rauscher <michlm...@gmx.de> wrote:
> >> mineshde...@gmail.com schrieb:

>
> >>> Hello,
> >>> I have a requirement in which i want to read a file from another
> >>> machine in the network. And also the machine is password protected.
> >> Which protocol?

>
> >>> Can any one help me out in this.
> >>> I tried doing it in following way,
> >>> URI uri = URI.create("file://9.182.198.145/shared");
> >>> File file = new File(uri);
> >>> As i excute this code i get an exception as:
> >>> java.lang.IllegalArgumentException: URI has an authority component
> >> Seems like the above is treated as UNC name which can't be used accross
> >> platforms. E. g. Linux would look for a file 'shared' in directory
> >> '9.182.198.145'.

>
> >> Under windows you might want to try
> >> "file://usernameassw...@9.182.198.145/shared"

>
> >> but perhaps it's easier to mount the share via

>
> >> net use X: \\9.182.198.145\Shared <password> /user:<username>

>
> >> and then access the file via X:

>
> >> Bye
> >> Michael

>
> > Michael Thanks for reply,

>
> > I will explain you the requirement,

>
> > I have few machines on the network, i want to access a file under
> > "shared" folder on the machine with i.p address as 9.182.198.145

>
> > and all the systems have windows OS.

>
> > One more thing i tried with following code and i got the same
> > exception

>
> Sorry, I was wrong.
>
> Either you've got access to the Share, then you can simply use the UNC
> name (\\9.182.198.145\Shared). Otherwise I thinkg you'd have to map the
> Share to a drive letter or to have a look athttp://jcifs.samba.org
>
> Bye
> Michael- Hide quoted text -
>
> - Show quoted text -


Correct me if iam wrong...

I have to Map the shared folder on my system then use the drive name
give to the mapped folder in file constructor.

Secondly,

Shared folder is password protected, so now what should be done?

Thanks
Minesh

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      03-14-2007
wrote:
> I have to Map the shared folder on my system then use the drive name
> give to the mapped folder in file constructor.
>
> Secondly,
>
> Shared folder is password protected, so now what should be done?


You have to provide the password when you mount the folder, so that part is
already done. In effect, the drive mapping idea pushes the security problem
out of Java space into user head space.

-- Lew
 
Reply With Quote
 
mineshdesai@gmail.com
Guest
Posts: n/a
 
      03-14-2007
On Mar 14, 6:35 pm, Lew <l...@nospam.lewscanon.com> wrote:
> mineshde...@gmail.com wrote:
> > I have to Map the shared folder on my system then use the drive name
> > give to the mapped folder in file constructor.

>
> > Secondly,

>
> > Shared folder is password protected, so now what should be done?

>
> You have to provide the password when you mount the folder, so that part is
> already done. In effect, the drive mapping idea pushes the security problem
> out of Java space into user head space.
>
> -- Lew


Is there any other alternative for this.
That is,
any alternative for mapping the folder into local drive.

because if server changes then i need to again map the folder. Thats
not feasible to do if i have to access many other machines.

-- Minesh

 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      03-14-2007
wrote:

> Is there any other alternative for this.
> That is,
> any alternative for mapping the folder into local drive.


jCIFS will probably do it.

http://jcifs.samba.org/

User-space implementation (in Java) of the SMB/CIFS network protocol which
underlies Windows shared filesystems. Client side only (as far as I know).

-- chris


 
Reply With Quote
 
Michael Rauscher
Guest
Posts: n/a
 
      03-14-2007
wrote:
> On Mar 14, 6:35 pm, Lew <l...@nospam.lewscanon.com> wrote:
>> mineshde...@gmail.com wrote:
>>> I have to Map the shared folder on my system then use the drive name
>>> give to the mapped folder in file constructor.
>>> Secondly,
>>> Shared folder is password protected, so now what should be done?

>> You have to provide the password when you mount the folder, so that part is
>> already done. In effect, the drive mapping idea pushes the security problem
>> out of Java space into user head space.
>>
>> -- Lew

>
> Is there any other alternative for this.
> That is,
> any alternative for mapping the folder into local drive.
>
> because if server changes then i need to again map the folder. Thats
> not feasible to do if i have to access many other machines.


I've already mentioned an alternative: http://jcifs.samba.org.

Bye
Michael


 
Reply With Quote
 
mineshdesai@gmail.com
Guest
Posts: n/a
 
      03-15-2007
On Mar 14, 11:30 pm, "Chris Uppal" <chris.up...@metagnostic.REMOVE-
THIS.org> wrote:
> mineshde...@gmail.com wrote:
> > Is there any other alternative for this.
> > That is,
> > any alternative for mapping the folder into local drive.

>
> jCIFS will probably do it.
>
> http://jcifs.samba.org/
>
> User-space implementation (in Java) of the SMB/CIFS network protocol which
> underlies Windows shared filesystems. Client side only (as far as I know).
>
> -- chris


Hey guys thanks for help, i was able to do it by using jCIFS

Bye
Minesh Desai

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 9.6 How do I download a file from the user's machine? How do I open a file on another machine? PerlFAQ Server Perl Misc 0 04-09-2011 04:00 PM
reading binary data from a 32 bit machine on 64 bit machine harijay Python 2 02-19-2009 08:31 PM
How to copy a file from one machine to another machine Nico Grubert Python 1 09-21-2005 10:53 AM
Re: How to copy a file from one machine to another machine Steve Holden Python 0 09-21-2005 10:29 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57