• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to copy a .doc file through java

 
Ramaswamy Narayanan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends

i need to copy a word file(.doc file) from one folder to another.
is it possible? if yes, how?
please help me immediately.
thank you
by
narayanan
 
Rawat (Zeon)
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

If it's just copying a file from one folder to another you can use copy method given below.


// Copies src file to dst file.
// If the dst file does not exist, it is created
void copy(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);

// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}

Thank,
Zeon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic