Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to a file on different machine

Status
Not open for further replies.

shine67

Programmer
Joined
Jan 11, 2002
Messages
41
Location
US
Hi,

server is running on unix machine and I want to create a file on my NT.

Code for that part is as follows:

File fout = new File("D:\\MyJava\\report.html");
FileOutputStream fileout = new FileOutputStream(fout);
fileout.write(bt, 0, str.length());

This doesn't produce any error message but I cannot find the file. When I switch the first line to

File fout = new File("data/report.html");

this works fine and creates the file on the server unix machine.

Can't I create any file on different machine? Is it because the server is running on different machine or because unix and nt machines are different?

I appreciate for any help.
Shine.
 
The problem is actually a bit of both.
Code:
 File fout = new File("D:\\MyJava\\report.html");
When it tries to save it on the Unix machine with this path it is probably throwing an exception (invalid path) that you are catching but not outputting text for. The reason for this is because you have not told it the file needs to be saved on another machine, so it is attempting to save it locally.

Do you have a filesharing system set up between the two computers? If so you might be able to write the file to a shared directory on the NT box. Or you might be able to FTP into it and upload a file. It all depends on how you have the security set on the NT box, what services are running, etc.

-Tarwn Experts are only people who have realized how much they will never know about a language.
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Thanks for the info.

Is there any way to embed ip addess or machine name in the file name, something like

File fout = new File("xxx.xxx.xxx.xxx\\D:\\MyJava\\report.html");


Thanks.
 
I've been working on a file sharing application in java which I believe relates to what you are trying to do. Why don't you create\find a file server program for your Unix machine and use a java client to get the file from the Unix machine? Simple File Transfer basically. Just a suggestion.

JavaDude32
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top