aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
Author

Junk value when converting .doc t .txt file

anu shree
Greenhorn

Joined: Apr 22, 2008
Posts: 2
import java.io.*;
class try2
{
public static void main(String[] args)

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

FileOutputStream fis1=new FileOutputStream("C:/read2.txt");
fis1.write(bytes);
fis1.close();
}
catch(Exception e)
{
System.out.println(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
Marshal

Joined: Mar 22, 2005
Posts: 41572
    
  54
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