File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Junk value when converting .doc t .txt 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 "Junk value when converting .doc t .txt file  " Watch "Junk value when converting .doc t .txt file  " New topic

Junk value when converting .doc t .txt file

anu shree

Joined: Apr 22, 2008
Posts: 2
class try2
public static void main(String[] args)

{ file = new File("C:/read1.doc");
FileInputStream fis = new FileInputStream(file);
byte bytes[] = new byte[fis.available()];;
System.out.println("Hello World! "+bytes.length);

FileOutputStream fis1=new FileOutputStream("C:/read2.txt");
catch(Exception e)

i am converting doc file to txt file.The file is getting created.The value which i am redaing junk
Can Any one Help me Please
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
This code isn't converting anything. It's reading a file, and storing it with a different extension.

It's rather hard to read -and make sense- of DOC files. If all you want to do is extract text from DOC files, then the Apache POI library can do that.

Alternatively, OpenOffice has a Java API that you can use; the JODConverter library makes it easier to use that to convert between file formats.
I agree. Here's the link:
subject: Junk value when converting .doc t .txt file
It's not a secret anymore!