How do I read and write to a file server? The File class is designed for local drives. I have not been able to find any examples.
Printable View
How do I read and write to a file server? The File class is designed for local drives. I have not been able to find any examples.
it depends on the kind of network protocol the file server is using.
ftp : commons-net project has a ftp client
window cifs: the jcifs project
another one that does both of these and nfs: JFtp - Open Source FTP, SFTP, NFS and SMB file transfer client and more
for http there is commons-http client (HTTP post/gets) dav4j (webDAV)
and if needing to use subversion, there is the svnkit project
there used to be an apache commons-vfs that provided sensible interfaces for all kinds of abstract file system back ends, so your application would compile against that, and any crazy file server protocol could be included as a module or kind of plugin to that.
Good grief. All I got to do is use the /Volumes/<file share>pathname! It just has to be mounted to use the Java File class. I've added the /Volumes/<file share> to the login items list for a user account who is automatically logged in on startup.
Is there a better way?
oh, well then if you can ensure the network share has been mounted by the operating system as /Volumes/${shareName} and the user executing the java program has the permissions to read/write files in this path, then this really behaves like any regular file on the file system, and using the standard java.io.File will work.
(e.g. searching for examples for Java read and write to a file should be good)