Hi all,
how can I write lines that I read from multiple files to one destination file in java??
the method write (FileWriter) can do this
When I read multiple files and save these line in string called for example "line" ..how can write line on the distination file? I want an helpful example for writing on file to understand that because I search on google but I don't get what I want ....
The method write that I used ...write only short string , and I want to copy contents of multiple files on one file....
Mar. Na.
-3
Junior Poster in Training
Recommended Answers
Jump to PostFirst that's poorly formatted code.
Second it looks like you read the last line from the file in lines 32 to 38. Let's call it a bad implementation. Try again. Some folk want others to write their code but it's best you see what's off and rewrite it.
Jump to PostYes you read and printed but then that loop ended with that one last line in the string variable. If you need to go back to basics in coding, do that but your code as-is is very borked.
Jump to PostYou know how to write one line (its in your code at line 59), so all you need to do is to place that inside your loop(s) so that its executed for each line that you read from the input files.
Jump to PostYes, keep trying! And remember, if you need help you should ALWAYS post the relevant code.
All 13 Replies
Mar. Na.
-3
Junior Poster in Training
rproffitt
2,580
"Nothing to see here."
Moderator
Mar. Na.
-3
Junior Poster in Training
Mar. Na.
-3
Junior Poster in Training
rproffitt
2,580
"Nothing to see here."
Moderator
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Mar. Na.
-3
Junior Poster in Training
Mar. Na.
-3
Junior Poster in Training
Mar. Na.
-3
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Mar. Na.
-3
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Mar. Na.
-3
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.