• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

problem opening a new word file

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
}
}
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can only guess that maybe the target directory doesn't exist?
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic