aspose file tools*
The moose likes I/O and Streams and the fly likes problem opening a new word file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "problem opening a new word file" Watch "problem opening a new word file" New topic
Author

problem opening a new word file

Vaibhav Deshpande
Ranch Hand

Joined: Apr 26, 2002
Posts: 33
Hi All,

I am just trying to read from one doc file and writing to another word doc file. this application runs file. But problem is that when i went to that directory and tries to open that new written word file it is not opening it showing error that some path problem taht is .
Document name or path is invalid.

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class filewriter {

public static void main (String[] args) throws IOException {

String readLine = "";
File tempfile = new File ("C:/test/test.doc");
File newFile = new File ("C:/test/resumes/result.doc");


try{
BufferedReader br = new BufferedReader(new FileReader(tempfile));

BufferedWriter out = new BufferedWriter( new FileWriter(newFile));

while ((readLine = br.readLine()) != null) {
out.write(readLine);
}
br.close();
out.close();
}catch(IOException e) {
System.out.println("exception");
e.printStackTrace();
}
System.out.println("no exception");
}
}
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I can only guess that maybe the target directory doesn't exist?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Dilip Fernandez
Greenhorn

Joined: Jan 03, 2003
Posts: 4
I am just trying to read from one doc file and writing to another word doc file. this application runs file. But problem is that when i went to that directory and tries to open that new written word file it is not opening it showing error that some path problem taht is .

Try using Input and Output streams instead of Readers and Writers. This works.

 
 
subject: problem opening a new word file