Bookmark Topic Watch Topic
  • New Topic

regarding conversion  RSS feed

 
kalyani guntupalli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all,i am a fresher ...
during the project i have come across one problem
after converting .gif to .doc,the doc file is not in readable format...
to make it readable what can i do??
my code is like this:

import java.io.*;
import java.util.zip.*;
public class ReadGif{
public static void main(String args[]) throws Exception{
FileInputStream fis=new FileInputStream("D:/Myapps/read/4843a349.gif") ;
FileOutputStream fos=new FileOutputStream("d:/Myapps/1.doc");

int dt;
while((dt=fis.read())!=-1){
fos.write((char)dt);
}
fis.close();
fos.close();
}
}
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
You did not "convert" the file. You renamed it with a different extension, and file extensions have nothing to do with the content of the file. The only way I know to "convert" an image into a Word Document would be to create a new word document and place the image into it. Open Office exposes a Java API that can be used to do that, but it is non-trivial.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Report post to moderator
Erm, that's not converting anything. All you are doing is writing the bytes of a GIF file into a file that has a *.DOC extension.

Actually taking a GIF image and writing into a valid Word document (I presume that's what the *.DOC extension is signifying) is quite a hard task.

There are third-party libraries that can help with this. But, unless I have misunderstood your question or your code, it seems like your general knowledge of computing would need to advance considerably, before you could successfully use such a library.

I would suggest trying some simpler tasks, and reading some good get-me-started books or Web-sites.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!