File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes copying files using fileReader, fileWriter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "copying files using fileReader, fileWriter" Watch "copying files using fileReader, fileWriter" New topic

copying files using fileReader, fileWriter

Bhasker Reddy
Ranch Hand

Joined: Jun 13, 2000
Posts: 176
public void copyfiles(String order_id) throws IOException {
File inputFile = new File("C:/XML/xmlfile.xml");
File outputFile = new File("C:/XML/" + order_id + ".xml");

FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);

int c;

while ((c = )!= -1)
System.out.println("Renaming the XML FILE");
I am copying files using this method.
Input file is 10kb(356 lines) and output file
is 8kb(309 lines). It's not copying the files
completely. It is not copying last 50 lines.
Does anyone have any idea regarding this.
I will appreciate

Bhasker Reddy
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
This topic is more appropriate for the IO and Streams forum. I will move it there for you.

Matthew Phillips
I agree. Here's the link:
subject: copying files using fileReader, fileWriter
It's not a secret anymore!