IntelliJ Java IDE
The moose likes I/O and Streams and the fly likes Regarding the conversion of local machine path Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "Regarding the conversion of local machine path" Watch "Regarding the conversion of local machine path" New topic
Author

Regarding the conversion of local machine path

Abhish Sharma
Greenhorn

Joined: Nov 14, 2011
Posts: 13
Hello friend ,
I am developing a program which reads some excel file from a remote computer and stores the path in UNC format. That is <machine name>\<shared folder name or say file path starting from shared folder>\<file name>.
I am storing the path in as local machine format right now. like wise c:\some_folder1\shared_folder\some_folder3\file.xls. But I need to store it as comp_name\shared_folder\some_folder3\file.xls. I know how to get all other, but How would i get to know the shared folder name and change my path acc. to my requirement. Yes this to note that I also retrived the name of all the shared folder through net share, but is not able to extract the name of local shared folder name. Can any one help me out in this???
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18368

If the current user has access to the share, you can just use java.io.File to work with the files. Just note that the file path must start with \\. When using that in a String you get \\\\. Alternatively, java.io.File is smart enough to convert any / into \ if needed, so you can also use only // (and then / to separate paths in the remainder of the path).


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Abhish Sharma
Greenhorn

Joined: Nov 14, 2011
Posts: 13
Rob Spoor wrote:If the current user has access to the share, you can just use java.io.File to work with the files. Just note that the file path must start with \\. When using that in a String you get \\\\. Alternatively, java.io.File is smart enough to convert any / into \ if needed, so you can also use only // (and then / to separate paths in the remainder of the path).



Thank you for replying sir, but i need the name of all the shared folder so that i change my file path acc. to requirement. So that if required i could later retrieve the file if required.
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18368

With java.io.File you can't get all the shares, because the share is the lowest part that's still a directory; the server itself (\\server) isn't.

Perhaps JCIFS does not have this limitation, and you can use SmbFile and its listFiles methods to find the shares themselves. I haven't used JCIFS myself so I couldn't tell you.
Abhish Sharma
Greenhorn

Joined: Nov 14, 2011
Posts: 13
Rob Spoor wrote:With java.io.File you can't get all the shares, because the share is the lowest part that's still a directory; the server itself (\\server) isn't.

Perhaps JCIFS does not have this limitation, and you can use SmbFile and its listFiles methods to find the shares themselves. I haven't used JCIFS myself so I couldn't tell you.



K. thanks for your concern
 
 
subject: Regarding the conversion of local machine path
 
Threads others viewed
Uploading and Downloading files
download files from UNC using jsp
File storage in VSS
Log message is not diplaying in my project using struts framework
accessing jsp project from LAN
MyEclipse, The Clear Choice