wood burning stoves 2.0*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
import java.io.*;
class try2
public static void main(String[] args)

java.io.File 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: 41128
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.

Ping & DNS - my free Android networking tools app
I agree. Here's the link: http://aspose.com/file-tools
subject: Junk value when converting .doc t .txt file
Similar Threads
need to generate RSA keys from txt files
file is empty, will fail
SequenceInputStream performance
Merging byte arrays using SequenceInputStream
Reading two files and Writing into another single file