?
Solved

Java - Copy files on a network share

Posted on 2012-08-29
6
Medium Priority
?
633 Views
Last Modified: 2012-09-04
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.
0
Comment
Question by:shanemay
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 38346002
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
 
LVL 9

Accepted Solution

by:
arioh earned 2000 total points
ID: 38352921
0
 

Author Closing Comment

by:shanemay
ID: 38357865
Thank you, that is what I am needing.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 38357874
Why would you need jcifs for that?
0
 

Author Comment

by:shanemay
ID: 38363467
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 38363482
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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question