Write data in doc file

Write data in doc file

How to write data or string in word file.

View Answers

February 4, 2011 at 12:29 PM

simply open the word document and type the string/text through keyboard..


February 4, 2011 at 12:52 PM

Hi Friend,

Try this:

import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import org.apache.poi.hwpf.usermodel.Range;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hwpf.extractor.WordExtractor;

public class WriteInDocument{

static void writeToFile(String content, String path){
try{
POIFSFileSystem fs = new POIFSFileSystem();
DirectoryEntry directory = fs.getRoot();
directory.createDocument("WordDocument", new ByteArrayInputStream(content.getBytes()));
FileOutputStream out = new FileOutputStream(path);
fs.writeFilesystem(out);
out.close();
}
catch(Exception ex) {
System.out.println(ex.getMessage());
                }
        }
                public static void main(String[]args){
                writeToFile("Hello World","c:/new.doc");
                }
}

For the above code, you need POI api.

Thanks


February 4, 2011 at 12:59 PM

Hi,

For the above code, poi-scratchpad-3.7-20101029.jar is needed.

Thanks


July 20, 2011 at 3:07 PM

now how do i do it when there are more than one statements to print i mean, getting data from databse and using that resultset object to print the data.. im doing it in jsp like, A a=new A(); a.getName() a.getAge() a.getAddress ...like wise , i want these data set to be printed on the word document.. pls help with this


July 20, 2011 at 3:09 PM

btw im gonna use servlet to print it on word... Krish


September 16, 2011 at 12:44 AM

hi .... how to use servlet ???









Related Tutorials/Questions & Answers:
Write data in doc file
Write data in doc file  How to write data or string in word file
how read data from doc file in same formate in jsp
how read data from doc file in same formate in jsp  how we can read and display data on jsp page, from doc file with the same formatting
Advertisements
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...{ String sCurrentLine; // Groped file name (Suresh.txt...(Exception ex){ //File file = new File("D:\\groupby.txt
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...{ String sCurrentLine; // Groped file name (Suresh.txt...(Exception ex){ //File file = new File("D:\\groupby.txt
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...{ String sCurrentLine; // Groped file name (Suresh.txt...(Exception ex){ //File file = new File("D:\\groupby.txt
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
Retrieve data from the database and write into ppt file
Java Retrieve data from the database & write into ppt file In this section, we are going to retrieve data from the database and write into the .ppt file. For this purpose, we have used Jakarta POI api to create a .ppt file. The class
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import...{ document.close();} %> </body> I added itextpdf jar file to the libraries.the pdf file are not opened when i execute the program.please send the code
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import...{ document.close();} %> </body> I added itextpdf jar file to the libraries.the pdf file are not opened when i execute the program.please send the code
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import...{ document.close();} %> </body> I added itextpdf jar file to the libraries.the pdf file are not opened when i execute the program.please send the code
write data to a pdf file when i run jsp page
write data to a pdf file when i run jsp page  Hi, <%@page import...{ document.close();} %> </body> I added itextpdf jar file to the libraries.the pdf file are not opened when i execute the program.please send the code
Retrieve Data from the database and write into excel file
Retrieve Data from the database and write into excel file. In this section, we are going to retrieve data from the database and write into the excel file...); fileOut.close(); System.out.println("Data is saved in excel file
write data to plist
write data to plist  How to write data to plist file in XCode
Convesion of txt file to doc file.??????
Convesion of txt file to doc file.??????  how to convert text file to doc file using java
doc file - Java Beginners
doc file   i want to read .doc file ?....it is a part of my project plz help. if possible , can anyone give me the code
Java Write to properties file
. Here we are going to create a .properties file and write data...Java Write to properties file In this section, you will learn how to write data to properties file.  The properties file is basically used to store
C file write example
C file write example       This section demonstrates you to write the data into the file. Here we are using the library function fwrite() to write the data into the file. You
Sort file data and write into another file
Sort file data and write into another file By sorting, you can arrange the data into meaningful order and analyze it more effectively. Here we have one file... and grade. The data is not properly arranged in the file. Now, we have to display
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java..., For writing some data in the file we require some class file, objects... the (BufferedReader) constructor. So that we write some data suing
Java write to file
Java write to file  How to write to a file in Java? Is there any... files. You can easily use the the FileWriter and BufferedWriter to write data to a text file. Here is the examples: Example program to write to file. File
serch document from .doc and .docx file
serch document from .doc and .docx file  how to find particular word from .doc and .docx file and that date insert into a data base
read doc and docx file in javascript
read doc and docx file in javascript  How i read doc and docx file in javascript
convert a file .doc to .zip
convert a file .doc to .zip  hiii, I uploaded a file with extension .doc now i required with .zip   Hi Friend, Try the following code...;TITLE>Display file upload form to the user</TITLE></HEAD> <
Reading .doc file using swing
Reading .doc file using swing  Sir, Could U Please Tell me the Way To Read .doc file in java using swing,with code
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
How to write a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter... this constructor data is written into a given file. If a value already exists..._TO_REPLACE_5 BufferedWriter: The BufferWriter class is used to write data from
Read and write file
Read and write file  HI, How to read and write file from Java program? Thanks   Hi, See the following tutorials: Java Write To File Read File Thanks
How to Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java... will be able to use OutputStreamWriter on a FileOutputStream classes to write data to a file from Java program. To write the Java Write To File we will use two
Write to a file
Write to a file   ...; the BufferedOutputStream class that store the data in an internal buffer and lets you write...; to the existed file. The given example uses the BufferedOutputstream
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program... the Examples of How to write to File in Java Program: WriteToFileExample.java import... how to write in a file."); br.close(); } catch (Exception e) { System.err.println
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?  import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class ReadFileExample
how to store/retrieve doc file - Java Beginners
how to store/retrieve doc file  i want to wirte a code that stores/ retrieves .doc files to the mysql database using jsp pages... can anyone help me with the code?  Use this stuff inside your jsp page for store file
How to read the .doc/ .docx file in Java Program
How to read the .doc/ .docx file in Java Program  Hi, I am beginner in Java programming language. Can anybody explain How to read .doc file in Java... throw all of the Word file data and the class WordExtractor extract the text
How to write properties file in java
Write properties file in java In this example we will discuss how to write property file in java. In this example We have write data to properties file. The properties file has fundamentally used to store the data configuration data
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
CREATE AND WRITE FILE THREAD JAVA
CREATE AND WRITE FILE THREAD JAVA  Hi guys I was wondering how can I make this program in java with threads. I need to create a file and write in it (i know how to do that) but by listening in some port all the data that is being
Java Write To File Binary
Java Write To File Binary In this tutorial you will learn how to write to binary file. A binary file is a file into which the bit patterns of mostly data types can be formed to a byte of 8 bits. Write to a binary file in java
How to write to file using FileOutputStream
How to write to file using FileOutputStream  Hi friends, Please help me in java program. How to write to file using FileOutputStream? thanks,   Hi, To write a file using FileOutputStream, we have to use
How to Write To File BufferedWriter in Java
How to Write To File BufferedWriter in Java  how to write to file... in Java.io package i.e. FileWriter and BufferedWriter file. In this section we... to write texts. In this classwe stores the character in a buffer to write
how to write file from FileInputStream
how to write file from FileInputStream  Hi, How to Write a file.... Thanks,   Hi, For Write to file from FileInputStream in java you may use... this website Write to file from FileInputStream in java
how to write to file at the end of the line
how to write to file at the end of the line  Hi, Where do i learn how to write to file at the end of the line using Java program. Plz suggest... will help you for "How to write the file at the end of line using Java language
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
Java Write To File Dom Document
Java Write To File Dom Document In this tutorial you will learn how to write to file dom document. Write to xml file you would be required to use the package...; Source src= new DOMSource(doc); File file = new File("
Java file read write operation
Java file read write operation  how to read and write the data from text file.Suppose i have text file with 4 fields name ,roll no ,marks1,marks2 with more than 20 records......i need to store these value in object and pass
How to write into CSV file in Java
How to write into CSV file in Java  How to write into CSV file in Java   Hi, To create Comma separated value(CSV) file is very simple... passed the file name to write into a stream characters. Then we use the FileWriter
how to write append file in Java
how to write append file in Java  How to write append file in Java   Hi, For append in the test new file or Appending a text earlier existing file should be retained when you are trying to write new contents
How to write to xml file in Java?
How to write to xml file in Java?  Hi Friends, Can anyone help me how to write in xml file in Java programming. Please fill free to give example or reference website for getting example.   Hi, To write in xml file
how to write java data - XML
how to write java data  how to write data to xml file  Hi friend, Read for more information, http://www.roseindia.net/xml/dom/ Thanks
Open a .doc file by click on the link using struts - Struts
Open a .doc file by click on the link using struts   I want to open a doc extension file when i click a link on jsp page .I know only about which is write in web.xml but not exactly know how i do this.Plz any one can help me
Java Write To File By Line
Java Write To File By Line In this tutorial you will learn how to write to file by line Write to a file by line using java you can use the newLine() method... how to write to file by line. In this example I have first created a new text

Ads