• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

copying files using fileReader, fileWriter

 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 = in.read() )!= -1)
out.write(c);
in.close();
out.close();
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
 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm stumped. I tried this code by copying a txt file (which I'm guessing all your XML file is) and it copied the entire file fine using your same code (I made the txt file with the same number of lines as yours).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic