473,378 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Convert the .doc file into .txt file

Hello
For my Application i want to convert .doc file (MS Word) into the
.txt file (Text). All of as says to use the (file) Save As method to do it. But i want to convert the file in Unix Using java. How is it possible, help to solve this.
Is there is any predifined tool to do this.

Thanks in Advance,
Geethu.
Mar 1 '07 #1
10 10999
DeMan
1,806 1GB
You would need to find a description of exactly how .doc files are stored (which is no simple matter), and then remove all the tags around the text.....

I'm not aware of any really simple way to do it, although you may find someone on the broader net has a public solution, because it seems to be a problem that comes up quite often....
Mar 1 '07 #2
r035198x
13,262 8TB
Hello
For my Application i want to convert .doc file (MS Word) into the
.txt file (Text). All of as says to use the (file) Save As method to do it. But i want to convert the file in Unix Using java. How is it possible, help to solve this.
Is there is any predifined tool to do this.

Thanks in Advance,
Geethu.
You can only read text portions of the word document into the text file.

Use the poi package to read the .doc file and write its contents to a file using FileWriter
Mar 1 '07 #3
rupanu
3
You can only read text portions of the word document into the text file.

Use the poi package to read the .doc file and write its contents to a file using FileWriter
Hi r035198x,
I have just joined this forum..
I am using POI for converting doc to txt...but it reads/wites only first line of the text....I don't know where its going wrong...Can u help me out with some code snippets?
Thanx rupanu
Mar 20 '07 #4
dmjpro
2,476 2GB
hello newbie ....

what is POI ??????
Mar 20 '07 #5
r035198x
13,262 8TB
Hi r035198x,
I have just joined this forum..
I am using POI for converting doc to txt...but it reads/wites only first line of the text....I don't know where its going wrong...Can u help me out with some code snippets?
Thanx rupanu
Post your code so we can take a look at it.
Mar 20 '07 #6
rupanu
3
hi there,
After trying with a few code snippets I found the following code working,but how do I read tables in the document???

//CODE

FileInputStream fis=new FileInputStream(filename);

HWPFDocument doc=new HWPFDocument(fis);

String str="";

Object[] textStack=doc.getTextTable().getTextPieces().toArr ay();

for (int i=0; i<textStack.length; i++)
{
if(str=="")
str=((TextPiece)textStack[i]).getStringBuffer().toString();
else
str=str+" "+((TextPiece)textStack[i]).getStringBuffer().toString();

}
//System.out.println(str);
FileWriter fw=new FileWriter("F:\\newdoc.txt");

fw.write(str);

fw.close();
///END of CODE

Please reply....
Mar 28 '07 #7
r035198x
13,262 8TB
hi there,
After trying with a few code snippets I found the following code working,but how do I read tables in the document???

//CODE

FileInputStream fis=new FileInputStream(filename);

HWPFDocument doc=new HWPFDocument(fis);

String str="";

Object[] textStack=doc.getTextTable().getTextPieces().toArr ay();

for (int i=0; i<textStack.length; i++)
{
if(str=="")
str=((TextPiece)textStack[i]).getStringBuffer().toString();
else
str=str+" "+((TextPiece)textStack[i]).getStringBuffer().toString();

}
//System.out.println(str);
FileWriter fw=new FileWriter("F:\\newdoc.txt");

fw.write(str);

fw.close();
///END of CODE

Please reply....
You will have to check the documentation for HWPF for that.
You should also consider using wrapping the FileWriter in a BufferedWriter
Mar 28 '07 #8
rupanu
3
Hello r035198x
The above code is unable to read openoffice.org documents i.e Open Document Text(.odt) format files.Can You pleas tell me how to read odt documents,I mean are there other APIs available for that?Please reply....
Apr 9 '07 #9
989898
4
Hi,
i have seen ur code which is very interesting,here i would like to know
What is Role of "Text Piece". i am getting an erro saying that it can't be resolved to type.
can u help me here, i know it is hard to ask u coz it is posted long back

thank u
vijay
Sep 29 '07 #10
989898
4
hi as per the code here i have just copied and done the same thing but iam getting an errorlike this

ava.io.FileNotFoundException: D:\123\12345 (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at com.poi.Testword.main(Testword.java:15)
but i have that file in that palce.can u help me here

vijay
Sep 29 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
3
by: Thubaiti | last post by:
Hi, I have this code in my ASP.NET and I want to convert it to C# (code behind) <asp:Repeater id="subCategoryRepeater" runat="server"> <ItemTemplate> <ul> <li> <asp:HyperLink...
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
5
by: melickas | last post by:
We designed a custom application using Office Developer Tools '97 which included a Run-time version of Access--- so it would not matter if our customer even had any version of Access on their...
6
by: PenguinPig | last post by:
Dear All Experts I would like to know how to convert a HTML into Image using C#. Or allow me contains HTML code (parsed) in Image? I also tried this way but it just display the character "<" &...
5
by: sonu | last post by:
hey good morning ...... how to convert a video file in .flv format in php for linux hosting......is there any package whis provide this facility . Can i use ffmpeg for linux hosting...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.