Java - Copy files on a network share

I have written an application that needs to place an xml file on a network share.  I am comfortable with, and have written the code to generate the file h. However, I have not found a good method of writing that file to a network share.  What I would like to do is take the file on the network share, rename it and over write the original every day.  In my research I have found many options like socket programming, ipc channels etc...  What would be best, does anyone have a code sample at which I could look? What would I need to address in the form of permissions?

Any help would be greatly appreciated.
shanemayAsked:
Who is Participating?
 
CEHJCommented:
File shared = new File("\\\\hostname\\sharename\\filename.xml")); // Now open a stream on 'shared'

Open in new window


The above assumes Windows. Let me know if that's not the case
0
 
shanemayAuthor Commented:
Thank you, that is what I am needing.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
CEHJCommented:
Why would you need jcifs for that?
0
 
shanemayAuthor Commented:
Because I need to copy / move files. Also, I have to deal with file share permissions, etc... If there is a better way to handle the file, I would be more than happy to look at it.  

Thank you for your help.
0
 
CEHJCommented:
What I would like to do is take the file on the network share, rename it and over write the original every day.  

was what i thought was your use case. The code i gave you will do that. If that's not your use case, then it could be that jcifs is necessary
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.