wood burning stoves 2.0
The moose likes Beginning Java and the fly likes help with writing file to new location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help with writing file to new location" Watch "help with writing file to new location" New topic

help with writing file to new location

Chris Evans

Joined: Apr 27, 2004
Posts: 3
The code right now will read in a file so that I can see the text, what I need to do and don't know how is take that text and replace it with other text along with adding txt. Then save it to a different location with a differnt name.
Can anyone help me out please.
Thank you in advance
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
What exactly are you having problems understanding? Where do you plan on going from here? What data do you need to add to the string that you read in? Where does it need to be added? What format is the data in the string when you read it in?
If you can answer these questions and give us any other details about what you are trying to do, we will be able to help you much more easily and quickly.

Java API Documentation
The Java Tutorial
Chris Evans

Joined: Apr 27, 2004
Posts: 3
My problem is that I'm fairly new to Java and I don't understand how to do this.
The first file is a .dat file(located at C:/Program Files/Client) I am already able to read this, but I need to make it look like the 2nd file(which won't exist yet)and save it in a different location. ex C:/program Files/Microsoft/
and saved as something.ctt
//1st file
G 289f9;80256d8c/Administrators3 Administrators O
G My;Group2 My;Group O
U william.flentje1:: william.flentje,bill.flentje
U bryan.miller1:: bryan.miller
U david.kratzer1:: david.kratzer,
U greg.mcbroom1:: greg.mcbroom,
G Test2 Test O
U kevin.leahy1:: kevin.leahy,
U marcia.lemon1:: marcia.lemon,
//2nd file to be created
<?xml version="1.0"?>
<service name="Microsoft">
[ April 28, 2004: Message edited by: Chris Evans ]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
The output file looks like XML. Are you required to write this text by hand or can you use any XML tools provided. From what I understand, Java provides classes that let you easily manipulate XML-style data, but I don't have any experience with this. I suspect that you should output the data as you read it from the file. By this I mean that each time you read a name from the first file, you can immediately write the appropriate line to the second file. Before you do this, you will also want to write the header information to the second file.
I'm assuming that you can figure out how to open a file to write to it. The process is very similar to reading from a file.
I hope this helps.
It is sorta covered in the JavaRanch Style Guide.
subject: help with writing file to new location