This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes how to copy a .doc file through java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "how to copy a .doc file through java" Watch "how to copy a .doc file through java" New topic
Author

how to copy a .doc file through java

Ramaswamy Narayanan
Greenhorn

Joined: Jan 19, 2005
Posts: 24
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

Joined: Feb 12, 2005
Posts: 5
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to copy a .doc file through java
 
Similar Threads
How to Copy All files with certain extensions from a directory and all its subs
Some know how to convert a file. Doc to image using java?
deploying a war in tomcat
Mikalai notes on one page
Read Word/PDF