File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 39551
    
  27
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 - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Junk value when converting .doc t .txt file
 
Similar Threads
file is empty, will fail
Reading two files and Writing into another single file
SequenceInputStream performance
Merging byte arrays using SequenceInputStream
need to generate RSA keys from txt files