Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help!!! please

 
Tina Guilder
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 files, in which the 2nd file needs to be inserted above the first file... I am totally lost.. if you can help it would be wonderful!!! thank you


Tina
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

I'm afraid I'm totally lost too. Can you be more specific about what you're asking? What are these "files"? And what do you mean by "insert"?
 
Tina Guilder
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
they are both text files, and a result of running the program is that the contents of the 2 file will be inserted about the first line of the 1st file...


Tina
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tina Guilder:
they are both text files, and a result of running the program is that the contents of the 2 file will be inserted about the first line of the 1st file...

Okay, so this sounds like an I/O problem. What do you have so far? Are you able to "read in" a file? Where exactly are you stuck?
 
Dianne Doss
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the result need to be in file 1,...or do you just need a result file that has the content of file 1 appended to the end of the content of file 2?
 
Tina Guilder
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made it so it creates file3.. I just cant get the information in the other files in there. do i have to do a sequencelist??? the 3rd file is successfully created, but no data
 
Tina Guilder
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is what i have so far




EDIT by mw: Added Code Tags to original poster's indentation.
[ August 23, 2006: Message edited by: marc weber ]
 
lajos kamocsay
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code is printing the strings "c:\\file2.txt" and "c:\\file1.txt" in file3...

If you want to copy the contents of those files, you need to open them , read them and write what you read in to file3.
 
Tina Guilder
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a string that makes it so it will automatically put the contents into the file.. because the purpose of this is so you dont have to keep typing it.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tina Guilder:
...the purpose of this is so you dont have to keep typing it.

I think lajos is suggesting that your program needs to "open them, read them, and write what you read..."

You already have File objects representing the two "input" files. But if you want to write their contents out to a third file, you first need to "read in" that content. Hint: You're already using a FileOutputStream to write out to the third file, so to read in the contents of the first two files, you could use a...
 
Tina Guilder
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fileinputstream???
 
Jody Brown
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tina Guilder:
fileinputstream???


That sounds like a winner to me. Or a FileInputStream to be precise.
[ August 23, 2006: Message edited by: Jody Brown ]
 
Tina Guilder
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you everyone for your help..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic