Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Reading a file from another machine on the network

Thread view: 
mineshdesai@gmail.com - 14 Mar 2007 11:46 GMT
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
Michael Rauscher - 14 Mar 2007 12:14 GMT
mineshdesai@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.
>
[quoted text clipped - 6 lines]
> 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://username:password@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
mineshdesai@gmail.com - 14 Mar 2007 13:20 GMT
> mineshde...@gmail.com schrieb:
>
[quoted text clipped - 31 lines]
> 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://username:password@9.182.198.145/shared");

File file = new File(uri);

can you please help me out in this.

Thanks
Michael Rauscher - 14 Mar 2007 13:53 GMT
mineshdesai@gmail.com schrieb:
>> mineshde...@gmail.com schrieb:
>>
[quoted text clipped - 36 lines]
> 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
mineshdesai@gmail.com - 14 Mar 2007 14:05 GMT
> mineshde...@gmail.com schrieb:
>
[quoted text clipped - 49 lines]
>
> - 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
Lew - 14 Mar 2007 14:35 GMT
> 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
mineshdesai@gmail.com - 14 Mar 2007 14:47 GMT
> mineshde...@gmail.com wrote:
> > I have to Map the shared folder on my system then use the drive name
[quoted text clipped - 9 lines]
>
> -- 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
Chris Uppal - 14 Mar 2007 19:30 GMT
> 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
mineshdesai@gmail.com - 15 Mar 2007 13:20 GMT
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.
[quoted text clipped - 9 lines]
>
>     -- chris

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

Bye
Minesh Desai
Michael Rauscher - 14 Mar 2007 20:02 GMT
>> mineshde...@gmail.com wrote:
>>> I have to Map the shared folder on my system then use the drive name
[quoted text clipped - 13 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.