Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with writing file to new location

 
Chris Evans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Regards,
Layne
 
Chris Evans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Version=3.1.3
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"?>
<messenger>
<service name="Microsoft">
<contactlist>
<contact>william.flentje@d.com</contact>
<contact>bryan.miller@d.com</contact>
<contact>david.kratzer@d.com</contact>
<contact>greg.mcbroom@d.com</contact>
<contact>kevin.leahy@d.com</contact>
<contact>marcia.lemon@d.com</contact>
</contactlist>
</service>
</messenger>
[ April 28, 2004: Message edited by: Chris Evans ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic