• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

create folder on remote system

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to create folder on the remote system using java code....
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To create a directory on remote machine you should have Read/Write access on the directory inside which you are going to create the directory

FolderName=<Path of remote machine's Directory>\<folder you want to create>

File defaultDir = new File(FolderName);
defaultDir.mkdir();
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the appropriate part of the remote system's filesystem is being made available to remote clients (via SMB, NFS, AFP etc.), with permission for the user running the Java code to write to it, then you can just use normal Java File operations like File.mkdir(). Of course, you need to use the right file path syntax; that's nothing to do with Java, but is a function of the operating system and the type of remote filesystem (SMB, NFS etc.)

If the part of the remote system's filesystem is not made available, then you cannot directly write to it with Java or with anything else ... thank goodness! In that situation, you would need to get the user of the remote system to agree to install a program of yours that would communicate with your server via the means of your choosing (sockets, RMI, CORBA, SOAP etc.). That program could do things like creating directories, in response to commands over the network from your server.
 
vara prasad
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok now ,like if i want to create a folder on local system i will give path like
File file=new File("C:\\folderpath");

But if have to create folder on remote system ,how to give the file path

File file=new File("10.112.32.122\\c:\\filepath"); ??? something like this
 
Saloon Keeper
Posts: 26011
186
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Peter said, you can't access files on other people's machines unless they have published some sort of file share via NFS, CIFS/SMB (also known as Windows Networking) or something like that.

IF, however, the machine named "JOESMITH" has decided to share out a directory named C:\MYSHARE, you can access is using Windows Networking - providing your machine can use that protocol. The filename would be in UNC form, so the best way would be like this:

File file=new File("//JOESMITH/MYSHARE/adirectory/myfile.dat");

Note that UNC names don't have drive letters in them, since drive letters are assigned relative to the client machine. Instead you use the machine ID and published sharename. You CAN use an IP address for the machine name, but since the machine name is more meaningful, I recommend you use it.

Also, you may have noticed that I used "real" slashes instead of backslashes. I recommend doing that, since it's more portable - and because since a backslash is also a Java escape character, you can make typing mistakes that can be hard to debug.
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic