wood burning stoves 2.0*
The moose likes Java in General and the fly likes Want to write a combined text file, but nothing happens.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Want to write a combined text file, but nothing happens.." Watch "Want to write a combined text file, but nothing happens.." New topic
Author

Want to write a combined text file, but nothing happens..

Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
Trying to take 2 files and combine them into one (preliminary code... Want to do more with it, but can't get this to work... )...
Any help would be appreciated..
Output.txt should have all lines from both input files.... this is probably easy, I'm just "mentally challenged" at this point.. :roll:
Thanks!
Program code:

Input file 1:

Input file 2:


CNSS/NSA Infosec Professional,<br />Software Engineer
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Sam,
I'm not really sure what the problem is. I couldn't immediately see a problem with the code, so I compiled it myself. Using the same inputs you used, this is my result:

This, as far as I can tell is the intended output. If this isn't what you're getting, perhaps it has something to do with a configuration issue. What version of Java are you using? I'm using Java 1.4.0.
If you were expecting something else, let me know and I can try to help you some more.
Corey


SCJP Tipline, etc.
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
yep, I get that with the system.out.println, but I need it to load the output.txt file with the same information (basically). Nothing gets written to the file....
UUURRRGGGHHHH!!! Brain Cramp!!!
Jonas Isberg
Ranch Hand

Joined: Mar 18, 2003
Posts: 118
I would have tried putting an out.close() last in main, maybe also an out.flush() before the out.close(). This to make sure that the file is properly closed.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by J Isberg:
I would have tried putting an out.close() last in main, maybe also an out.flush() before the out.close(). This to make sure that the file is properly closed.

Indeed - add the out.close() statement to the end and the output.txt file gets populated. Sorry I didn't understand what you wanted the first time.
Sam Smoot
Ranch Hand

Joined: Apr 18, 2002
Posts: 238
Guess that's like closing the gate once you put the cows in... they won't stay if you don't...
That worked....
Thanks!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want to write a combined text file, but nothing happens..
 
Similar Threads
What should be Regex??
Threads output
IO
problem in IO reader
why doesn't this work?