Read a doc file and write back to a doc file

How to read line by line from a doc file and then arrange it.
Like-->
amit
sumit
prem
jeev
these four names are present in the doc file. Now how to read by means of java program and sort these names and write back to a new doc file?????
What packages and methods are to be used??
Please help.....
Edited by: Jaguar on Apr 11, 2011 12:16 AM

Jaguar wrote:
How to read line by line from a doc file and then arrange it.By 'doc' do you mean MS Word?
these four names are present in the doc file. Now how to read by means of java program and sort these names and write back to a new doc file?????You seem to have a sticky '?' key and an unreliable shift key (to apply an upper case letter to the start of every sentence). Please fix them.

Similar Messages

  • A need a function module to read a file and write back into it

    Hello ,
    My requirement is to provide the path to a file , read the file contents and then write back to it.
    Thanks,
    Mridu.

    Hi ,
    Use combination of these three FM's , A nice documentation is given for them by SAP .
    1.)  F4_FILENAME
    2.) GUI_UPLOAD
    3.) GUI_DOWNLOAD
    revert back if any queries
    reward points if helpful

  • Read from a file and write back

    Hi,
    I'm trying to read from a text file, and stor into a vector of vectors.
    This part works fine
    then i want to randomly split the vector into 2 different vectors a training set and a test set.
    this part woks fine too.
    now i want to write each of these vectors to a text file........this is the part i'm stuck on.
    some of my code is below:
    public static void main(String[] args)
              Vector Train;
              //Vector Test;
              Split s = new Split();
              Vector data = s.readFile("diabetes.txt");
              Vector Test = s.split(data);
              Train = s.getTrainingVector();
              //Training.txt = s.writeToFile(Training, "Training.txt");
              //Test.txt = s.writeToFile(data, "Test.txt");
              File Training = new File("Training.txt");
              File Testing = new File("Test.txt");
              FileWriter out = new FileWriter(Training);
              for(int i =0; i<Train.size(); i++)
                   out.write(Train.get(i));
                   out.write("\n");
              out.close();
              FileWriter out2 = new FileWriter(Test);
              for(int i =0; i<Test.size(); i++)
                   out2.write(Test.get(i));
                   out2.write("\n");
              out2.close();
         }Can anybody help?
    Cheers

    i've tried that but i'm getting this error:
    cannot resolve symbol
    symbol : method write (java.lang.Float)
    location: class java.io.FileWriter
    out.write((Float)(InnerVec.get(i)));
    does it have to be Strings?

  • CAN AN EXCEL XLSM FILE READ FROM A CSV AND WRITE BACK TO THE SAME XLSM -VBA

    Hey Carlos- Here's the repost. 
    Could an XLSM file read a line from a CSV file in "A1" and depending on what was in the first column in the XLSM, search the CSV file and find the indexed item in the second column or third? I've done it before with standard VLookup functions and it was cumbersome and very slow, and for some reason, everytime I would save the file it would take forever although the xls file was a single sheet.
    i've attacthed a sketch of what I'm talking about, because it's hard to explain and I think the sketch explains it better. Here it is, sorry if it is blurry, it looked fine before I posted:

    ok, use this version, I changed it a bit. To accommodate the issue with the single cell, I moved the main procedures to a function for a more efficient use.
    Sub xlsmCsvLookup()
        'have both your xlsm and your csv files open
        'in the xlsm file, select a range of cells to look up
        'run the script to search all selected cells and get the values from the csv file
        Dim csvDataRange As Range 'csv file data column
        Dim selRange As Range 'to hold selected cells
        Dim foundRange As Range
        'get the source range
        Set csvDataRange = Workbooks("Book2.csv").Sheets(1).Range("a:a") ' replace "Book2" with yourCSVfile.csv
        'check for selection, only one cell, ceck that cell and exit, otherwise loop thru selection
        If Selection.Count > 1 Then
            'loop thru all selected cells, ignore empty cells
            For Each selRange In Selection.SpecialCells(xlCellTypeConstants)
                findSelection selRange, csvDataRange
            Next
        Else
            findSelection ActiveCell, csvDataRange
        End If
        Set foundRange = Nothing
        Set selRange = Nothing
        Set csvDataRange = Nothing
    End Sub
    Function findSelection(selRange, csvDataRange)
            'try to find it in the csv file
            Set foundRange = csvDataRange.Find(selRange) 'if found, assign it to foundRange
            'if no match highligh cut
            If foundRange Is Nothing Then
                selRange.Interior.ColorIndex = 34
            Else
                'if found, get the value in next cell
                selRange.Offset(0, 1) = foundRange.Offset(0, 1)
            End If
    End Function

  • Read multiple files and write data on a single  file in java

    Hello,
    I am facing difficulty that I want to read multiple files in java and write their data to a single file. Means Write data in one file from multiple files in java
    Please help me out.
    Naveed.

    algorithm should be something like:
    File uniqueFile = new File();
    for (File f : manyFilesToRead)
       while (readingF)
           write(dataFromF, intoUniqueFile);

  • Read data from db and write it into the txt file

    hi all
    could anyone please help me regarding the following:
    i would like to read the data from database using sql query and the write the data into a text file.
    I am able to connect the db, run the query, create file...but not knowing how to write the data into the file.
    could anyone please help me out.
    thanks in advance
    regards
    sasasa
    Edited by: sasasa on Sep 14, 2009 8:57 AM

    i would like to read the data from database using sql query and the write the data into a text file.
    I am able to connect the db, run the query, create file...but not knowing how to write the data into the file.
    There must be something that I am missing.
    How is it possible to be able to navigate JDBC, run a query and create a file but not know how to write to it?

  • Screen data entry box that displays data from text file AND write back to file.

    I want the user to be able to view/edit a 'setup file' FROM THE SAME INDICATOR BOXES for a application. I tried to read the file(text), display individual data in indicator boxes and re-write file when user is finished. This causes errors since you can't use indicators boxes as inputs for the file write. Is there some kind of indicator/control/data entry box that the user can view the data, edit the data, and re-write the data from the box???

    hi
    I have created this example for your reference.
    I modified the Configuration File Examples in LV Examples, together with a few file check & create functions.
    Hope this will help.
    Note: The Configuration File Example from LV are COOL, indeed.
    Cheers
    ian.f
    Ian F
    Since LabVIEW 5.1... 7.1.1... 2009, 2010
    依恩与LabVIEW
    LVVILIB.blogspot.com
    Attachments:
    iFunc_Setup_Config_File.zip ‏102 KB

  • Find a string in a file and write a new text after it

    hi
    i try to search a string in a small text file. after this position I should write a new text (it is not the end of the text, it could be somewhere between).
    I tried to solve this with the StrginTokenizer, but it does not work properly, any other ideas how to solve this?
    thanks for your comments
    steinfresser

    To insert text into the middle of a file you use the process that has been used since the first text editor was invented over 50 years ago:
    1. Read the text from the file up to the insert point, and write it to a new file.
    2. Write the inserted text to the new file.
    3. Read the rest of the text from the file, and write it to the new file.
    4. Delete the file.
    5. Rename the new file.

  • Reading an XML file and write the contents to another xml file in java

    Hi,
    I am new to xml parsing.My requirement is that I am getting a message (xml) using ibm MQ in the ByteArrayInputStream format.I have to read this xml message and write to another file.
    I am creating a POC for this.
    First I used simple reading and writing concept but the output is "java.io.FileInputStream@3e25a5 "
    Sample xml file
    - <Client>
    <ClientId>1234</ClientId>
    <ClientName>STechnology</ClientName>
    <DTU_ID>567</DTU_ID>
    <ClientStatus>ACTIVE</ClientStatus>
    - <LEAccount>
    <ClientLE>678989</ClientLE>
    <LEId>56743</LEId>
    - <Account>
    <AccountNumber>9876543678</AccountNumber>
    </Account>
    </LEAccount>
    - <Service>
    <Cindicator>Y2Y</Cindicator>
    <PrefCode>980</PrefCode>
    <BSCode>876</BSCode>
    <MandatoryContent>MSP</MandatoryContent>
    </Service>
    </Client>
    code:
    import java.io.ByteArrayInputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class ByteArrayInputStreamToXml {
         public static void main(String srg[]) throws IOException{
              InputStream inputStream= new FileInputStream("C:\\soft\\test2\\sample1.xml");
              byte currentXMLBytes[] = inputStream.toString().getBytes();
              ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes);
              OutputStream out = new FileOutputStream("C:\\soft\\test\\data.xml");
              int read=0;
              byte[] bytes = new byte[1024];
              while((read = byteArrayInputStream.read(bytes))!= -1){
              out.write(bytes, 0, read);
              out.write( '\n' );
              inputStream.close();
              out.flush();
              out.close();
              System.out.println("New file created!");
    Please suggest me how can I use DOM/SAX parser ,I can see several code on net for reading xml file using SAX/DOM parser but writing an xml file after reading it using ByteArrayInputStream I am not getting .A help through some example Link will also be helpful for me.
    Thanks
    Sumit
    Edited by: user8687839 on Apr 30, 2012 2:37 AM
    Edited by: user8687839 on Apr 30, 2012 2:43 AM

    Thanks I got the result.
    package com.sumit.collections;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    public class ByteArrayInputStreamToXml {
         public static void main(String srg[]) throws IOException{
              InputStream inputStream= new FileInputStream("C:\\soft\\test2\\sample1.xml");
              ByteArrayOutputStream buffer = new ByteArrayOutputStream();
              int nRead; byte[] data = new byte[1024];
              while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
              buffer.write(data, 0, nRead); } buffer.flush();
              byte currentXMLBytes[]= buffer.toByteArray();
              /* byte currentXMLBytes[] = inputStream.toString().getBytes();*/
              ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(currentXMLBytes);
              OutputStream out = new FileOutputStream("C:\\soft\\test\\data.xml");
              int read=0;
              byte[] bytes = new byte[1024];
              while((read = byteArrayInputStream.read(bytes))!= -1){
              out.write(bytes, 0, read);
              out.write( '\n' );
              inputStream.close();
              out.flush();
              out.close();
              System.out.println("New file created!");
    }

  • How to read and write a data from extrenal file

    Hi..
    How to read and write a data from extrenal file using Pl/sql?
    Is it possible from Dyanamic Sql or any other way?
    Reagards
    Raju

    utl_file
    Re: How to Create text(dat) file.
    Message was edited by:
    jeneesh

  • Using cfhttp to read a page and write its contents to a file.

    Hi,
    I am trying to get a feed of my ebay store listings to load
    into froogle. Unfortunately, ebay provides the feed as a website
    not a file and froogle (via GoogleBase) needs the file to be
    submitted as an XML file.
    Is there a way to use something like cfhttp to load up the
    page where the feed is located, scan the page and write it's
    contents into an XML file that I can then load up to GoogleBase???
    thanks for the help.

    ignore me now.... I answered my own question a short while
    ago.
    for anyone who cares....
    I used CFHTTP to get the page and then used a cffile to write
    the #cfhttp.filecontent# into the new file!

  • How to read from one file and write into another file?

    Hi,
    I am trying to read a File and write into another file.This is the code that i am using.But what happens is last line is only getting written..How to resolve this.the code is as follows,
    public String get() {
         FileReader fr;
         try {
              fr = new FileReader(f);
              String str;
              BufferedReader br = new BufferedReader(fr);
              try {
                   while((str= br.readLine())!=null){
                   generate=str;     
              } catch (IOException e1) {
                   e1.printStackTrace();
              } }catch (FileNotFoundException e) {
                   e.printStackTrace();
         return generate;
    where generate is a string declared globally.
    how to go about it?
    Thanks for your reply in advance

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • Re: want to read in from file and write to components like textfield

    I have a file that has been written using PrintWriter
    The file is written with only the escape character '\t'
    formating and not '\n'
    here is 'file.txt':
    s a     Alan     Credit Account     333333     55555     3     March     1972     20000.0     mmilo
    I now want to read this and write to various components eg. Textfield
    textfield.setText(readinText);
    The file is written with these commands:
    myprint.print(initials);
    myprint.print('\t');
    myprint.print(surname);
    myprint.print('\t');
    so basicly initials '\t' surname '\t' card type '\t' etc
    How can I read this file and write to the components?
    I am thinking of using BufferedReader
    is this o.k?
    String str;
    try
    { BufferedReader myinp;
    myinp = new BufferedReader( new FileReader("file.txt"));
    while ((str = myinp.readLine()) !=null)
    { //this is where I need help, given that i have
    // just read in a line how can I seperate it
    // i.e initials, surname, card type etc?
    // please help
    myinp.close();
    catch(IOException e)
    { System.err.println("Exception: " + e.getMessage());
    System.exit(1);
    }

    Hi,
    1. read in the whole file in a string
    2. then do the following - lets say s is your readin string
    StringTokenizer st = new StringTokenizer(s,"\t");
    the StringTokenizer separates that automatically for you - every call to st.nextToken() returns a string with one "value", the "\t" is not returned. Let's say you have 4 JTextFields called tf1 to tf4 and you want to fill in the 4 values from the StringTokenizer
    tf1.setText(st.nextToken());
    tf2.setText(st.nextToken());
    tf3.setText(st.nextToken());
    tf4.setText(st.nextToken());
    how many values are readable by nextToken()-calls are returned by st.getTokenCount() and you can ask if there are more to read by st.hasMoreTokens() which return a boolean.
    greetings Marsian

  • How to  read from excel file and write it using implicit jsp out object

    our code is as below:Please give us proper solution.
    we are reading from Excel file and writing in dynamicaly generated Excel file.it is writing but not as original excel sheet.we are using response.setContentType and response.setHeader for generating pop up for saveing the original file in to dynamically generated Excel file.
    <%@ page contentType="application/vnd.ms-excel" %>
    <%     
         //String dLoadFile = (String)request.getParameter("jspname1");
         String dLoadFile = "c:/purge_trns_nav.xls" ;
         File f = new File(dLoadFile);
         //set the content type(can be excel/word/powerpoint etc..)
         response.setContentType ("application/msexcel");
         //get the file name
         String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
         //set the header and also the Name by which user will be prompted to save
         response.setHeader ("Content-Disposition", "attachment;     filename="+name);
         //OPen an input stream to the file and post the file contents thru the
         //servlet output stream to the client m/c
              FileInputStream in = new FileInputStream(f);
              //ServletOutputStream outs = response.getOutputStream();
              int bit = 10;
              int i = 0;
              try {
                        while (bit >= 0) {
                        bit = in.read();
                        out.write(bit) ;
    } catch (IOException ioe) { ioe.printStackTrace(System.out); }
              out.flush();
    out.close();
    in.close();     
    %>

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • Reading Data from Unix file and write into an Internal table

    Dear all,
                     I am having an requirement of reading data from unix file and write the same into an internal table..how to do that ...experts please help me in this regard.

    Hi,
    do like this
    PARAMETERS: p_unix LIKE rlgrap-filename OBLIGATORY.
    DATA: v_buffer(2047) TYPE c.
    DATA: BEGIN OF i_buffer OCCURS 0,
            line(2047) TYPE c,
    END OF i_buffer.
    * Open the unix file..
    OPEN DATASET p_unix FOR INPUT IN TEXT MODE.
    <b>IF sy-subrc NE 0.
    *** Error Message "Unable to open file.
    ELSE.</b>
       DO.
         CLEAR: v_buffer.
         READ DATASET p_unix INTO v_buffer.
         IF sy-subrc NE 0.
            EXIT.
         ENDIF.
         MOVE v_buffer TO i_buffer.
         APPEND i_buffer.
      ENDDO.
    ENDIF.
    CLOSE DATASET p_unix.
    <b>Reward points if it helps,</b>
    Satish

Maybe you are looking for

  • Switch apple id to previously used email address

    I am trying to switch my apple id from my school email address to my gmail address because I am graduating soon. However, when I try to switch it to my gmail, it says that I have already used the gmail as my apple id before, but I don't think I have.

  • Execute Stored Procedure from C#

    Hi, im new to using stored procedures and i have the following stored procedure... CREATE OR REPLACE PROCEDURE DRL_PROCEDURE2(var_SOURCE_OBJECTID IN varchar2, var_NEW_OBJECTID OUT varchar2) AS BEGIN SELECT MAX(NEW_OBJECTID) INTO var_NEW_OBJECTID FROM

  • Enterprise Services list in Discovery System.

    Hi, I just want to know the Enterprise services list in Discovery system. Actually why i needed that, is just wanted to know is there any enterprise service available for Billing, Service Order Management that are present as functionality in  SAP CCS

  • Fbs 10g error with ant make

    I got error when i do ant make 1. Is this normal to have exception like below. "[java] Exception during compile, trying again with shorter command line" 2. It says Pakage "oracle.j2ee.ws.common...." does not exist. Where to find these pakages or ...

  • Kill of the hang program...

    Hi .. is there any way to kill off the hang program using java... lets say i have this code below.. try{ a.print(); a.runPrint(); -------------> hang here and does not even throw exception System.out.println("hi"); }catch(exception e) System.out.prin