Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem opening a new word file

 
Vaibhav Deshpande
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can only guess that maybe the target directory doesn't exist?
 
Dilip Fernandez
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic