How to read the content of a text file (by character)?

Guys,
Good day!
I'm back just need again your help. Is there anyone knows how to read the content of a text file not by line but by character.
Please help me. Thank you so much in advance.
Jojo

http://java.sun.com/javase/6/docs/api/index.html
package java.io
InputStream.read(): int
Reads the next byte of data from the input stream.
Implementation:
InputStreamReader
An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.

Similar Messages

  • How to read the contents of a text file and populate the data in a table ?

    Hello All,
      Can anyone advise on how to acheieve the above ? I am trying to read in a text file (CSV) and have the contents populated to the respective UI elements in a table. Any help is greatly appreciated.
    from
    Kwok Wei

    Hi,
    Let us consider you have list of names(Seperated by delimeter) in a text file and you want to display in  a table.
    1. Create Context Node "Names" and context attribute "Name"
    2. Create Table and bind to the above context.
    3.Write the following code in the "Init method.
    try{
    FileReader f =new FileReader("");
    BufferedReader r=new BufferedReader(f);
    String names=r.readLine();
    Vector Names=new Vector();
    // Use Tokenizer and store all the names i a vector//
    for(int i=0;i<Names.size();i++){
    IPrivate<<VieName>>.INameElement ele=wdContext.createNameElement();
    ele.set<<Name>>( Names.get(i).toString());
    wdContext.NodeName().addElement(ele);
    Regards, Anilkumar
    Message was edited by: Anilkumar Vippagunta

  • How to read the content of ms-word file use pure java???

    how to read the content of ms-word file use pure java???

    hi,
    check this: http://jakarta.apache.org/poi/

  • How to read the content of this excel file in LV

    Hi could you please let me know how can I read the content of this excel file using the Read From Speardsheet function. It contains text and numbers
    Thanks
    The excel file is attached
    Attachments:
    Datalogging.zip ‏307 KB

    Check attached VI.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.
    Attachments:
    ReadFromExcel.vi ‏27 KB

  • Help on how to read the content of an XML file from the payload

    I have a receiver channel / mail adapter, that sends e-mails with a XML attachment.
    I’m trying to write a Bean, that should make it possible to rename the attached XML file dynamically.
    In the Bean I want to read the content of the attached XML file, it could be the “order number”.
    The filename should then be “Order number”.XML.
    <u><i>Can anyone help me with how to read the content of the XML file from the payload.</i></u>
    <i><b>Frank</b></i>

    hi,
    check this: http://jakarta.apache.org/poi/

  • How to store the contents of a text file directly in to a clob field

    Hi All,
    Could anyone help me to store the contents of a text file (*.txt,*.xml etc)directly in to a clob field.
    Thanks in advance
    Jayaram.

    One way is to use sqlloader. Three files are used. A control file, an xml data file, and a file with the path of the xml data file. Here's the control file. It reads load.file, which is the file with the path of the xml data file. It names the path ext_path, and inserts the xml into field xml_field.
    CONTENTS OF CONTROL FILE:
    load DATA
    INFILE 'load.file'
    APPEND
    INTO TABLE xml_table
    ( ext_path FILLER CHAR(13),
    "XML_FIELD" LOBFILE(ext_fname) TERMINATED BY EOF
    CONTENTS OF FILE LOAD.FILE:
    /tmp/load.dat
    The xml is in the file /tmp/load.dat.
    null

  • I want to read the content of a text file dropped in a watched folder into a string variable

    I have a workbench process with 2 variable.
    inDoc (DataType=Document/input/required)
    outStr (DataType = String/output)
    The document being passed to the workflow is a text file with 4 lines of text in it.  when the text file is dropped into the watched folder, it will be assigned to the inDoc parameter in the workflow.
    My workflow needs to extract the 4 lines of text and write it into a string (outStr).
    Id like to use the FileUtilsService.ReadString service but i can't since its input parameter is the file path.  When i do, i get the following error...
    Caused by: ALC-FUT-001-011: File rO0ABXNyABZjb20uYWRvYmUuaWRwLkRvY3VtZW50yAEFUxsO+CEDACNJAAtfY2FsbGJhY2tJZFoADV9kZXNlcmlhb Gl6ZWRJABBfZGlzcG9zYWxUaW1lb3V0WgAJX2Rpc3Bvc2VkWgAZX2lzRGlzcG9zYWxUaW1lb3V0RGVmYXVsdFoAE19 pc1RyYW5zYWN0aW9uQm91bmRKAAdfbGVuZ3RoSQAOX21heElubGluZVNpemVaAAhfb3duRmlsZVoAC19wYXNzaXZhd GVkWgALX3BlcnNpc3RlbnRJABFfc2VuZGVyQ2FsbGJhY2tJZFoAEV9zZW5kZXJQYXNzaXZhdGVkWgARX3NlbmRlclB lcnNpc3RlbnRJAA5fc2V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readDocument(FileUtilsService.java:363)
    which is what i expected...
    I've also tried with the Script.executeScript to call some java code but im not too strong in java and in all the examples i find, the file pointer requires a file path.
    import java.io.*;
    FileInputStream f = new FileInputStream(patExecContext.getProcessDataValue("/process_data/inDoc"));
    OR
    File f = new File(patExecContext.getProcessDataValue("/process_data/inDoc"));
    OR
    File f = patExecContext.getProcessDataValue("/process_data/inDoc");
    Any clue how to resolve my problem?

    Try the following code snippet to read the String content from the file recieved through watched folder endpoint.
    com.adobe.idp.Document inputDoc = patExecContext.getProcessDataDocumentValue("/process_data/inDoc");
    java.io.InputStream inStream = inputDoc.getInputStream();
    byte[] dataBuffer = new byte[inStream.available()];
    inStream.read(dataBuffer);
    String strData = new String(dataBuffer);
    patExecContext.setProcessDataStringValue("/process_data/outStr",strData);
    The code is not tested, hence if you find any mistakes, correct and test the functionality.
    Nith

  • How to modify the contents of a text file stored along with a midlet

    Hi,
    I have been developing a application in j2me wherein i need to first read the contents of the text file stored along with the midlet and later erase the existing content and update it with some text.
    I was able to read the file in the following manner
    InputStream is = getClass().getResourceAsStream("myfile.txt");
    Now i need to erase the contents and then update it the new content, how do i do it. Kinldy please help me out. It is very urgent.
    Thanks

    Didn't you hear me the first time?
    http://forum.java.sun.com/thread.jspa?threadID=701360&messageID=4068435#4068435

  • URGENT: How to read the content of a PDF-file in Java?

    Hello
    What I need are some classes which can read a pdf and translate it in normal Text, so that I can write the content of the pdf in my database.
    Where can I find those classes? Or how else could I get there?

    www.lowagie.com/itext
    www.etymon.com/pj
    www.retep.org.uk/pdf
    www.pdflib.comwww.pdfzone.com
    www.planetpdf.com
    www.purepdf.com
    www.adobe.com
    www.pdfstore.com
    www.adobe.com/proindex/acrobat/formsresources.html
    www.partners.adobe.com/asn/developer/acrosdk/forms.html
    www.rrsys.com
    www.javafoundry.com/javapdf
    www.novagraphix.com/internet_publishing_with_acrobat/forms/forms_tutorial.html
    www.binarything.com

  • How to check the content in a text file line

    hi all,
    i had the following problem:
    There is a text file with multiple lines of data in it
    The data comprises of characters, numbers and symbols
    In this file, any line can be commented (till the end) by using symbol ';'(semi-colon)
    Now i have to find the number of occurences of a symbol '$' in this data, such that
    it should not exist in a commented line
    One more limitation is that ';' (semi-colon) could occur at any position in a line, i.e., if this occured in the middle of the line, then all the following data in the line is taken to be as commented one and we have to skip it and move to next line.
    Plz do help.
    Regards,
    santosh
    Regards,
    santosh

    Hi santosh,
    just a guess this is what you need.
    Greets, Dave
    Message Edited by daveTW on 09-15-2006 09:59 AM
    Greets, Dave
    Attachments:
    search & count $.vi ‏13 KB
    search & count $.png ‏10 KB

  • How to display the contents of a text file on the command line?

    I realize I need to utilize classes from the java.io.* package, but I don't know which ones to use exactly. This is what I would like to do in a nutshell:
    public static void main(String[] args) throws IOException {
    File inputFile = new File( <path to the file>);
    // code that reads data from the above file and is able to
    // append it to  a string object or display it on the command
    // line (System.out.println)
    }Thanks for your time!

    It's pretty easy. Here's a little example that reads a file, stores it in a string, and prints it to the command line.
    import java.io.*;
    public class OpenFile {
         public static void main(String args[]) {
              try {
                   File fileToOpen = new File("something.txt");
                   FileReader fileIn = new FileReader(fileToOpen);
                   BufferedReader br = new BufferedReader(fileIn);
                   String fileContent = new String();
                   String line;
                   while ((line = br.readLine()) != null) {
                        fileContent += line + "\n";
                   System.out.println(fileContent);
                   br.close();
              catch (IOException e) {
                   System.out.println("Exception: " + e);
    }Good luck,
    Alex

  • How to read the content in one node of XML in Java? Pls help

    My dear brothers,
    I am a newbie of XML, I have a exercise which is creating a Tree View from XML file. But the trouble is I do not know how to read the content in one node of XML file. I decide to use the algorithm as following:
    1. Create a GUI form which gives the ability for user to choose a XML file (ok)
    2. Load XML and return the file (ok)
    3. Read the file from node to node to create the node in Tree View (?!)
    Please help me, and if you are enough kind, please give me an small example to easy understand. Thanks in advance.
    Hoang Yen Binh

    I hope this one helps you.
         <ABC Type="ProductBased" ProdName="One" Location="India">
              <CEO>Raj</CEO>
              <Finance>Vikram</Finance>
              <HR>Karthik</HR>
              <Technical>Satish</Technical>
         </ABC>
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Attr;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.w3c.dom.DOMException;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import java.io.File;
    import java.io.IOException;
    public class XmlReading {
         Document doc;
         Element element;
         public static void main(String[] args) throws Exception{
              XmlReading xr = new XmlReading();
              xr.getXmlParser(args);
         public void getXmlParser(String[] args) {
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   if(args.length != 1) {
                        System.err.println("Argument Required");
              try {
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   doc = builder.parse(new File(args[0]));
              }catch(ParserConfigurationException e1) {
              }catch(SAXException e2) {
              }catch(IOException e3) {
              getAttributes();
         public void getAttributes() {
              // Retrive the entire Document from the Dom Tree
              element = doc.getDocumentElement();
    //          System.out.println(element);
              NamedNodeMap attrs = element.getAttributes();
              // Get number of attributes in the element
         int numAttrs = attrs.getLength();
         // Process each attribute
              for (int i=0; i<numAttrs; i++) {
                   Node node = attrs.item(i);
                   // Get attribute name and value
                   String attrName = node.getNodeName();
                   String attrValue = node.getNodeValue();
                   System.out.println(attrName + ": " + attrValue);
              String s1 = element.getTagName();
              System.out.println(s1);
              // To get all the elements in a DOM Tree
              NodeList nl1 = element.getElementsByTagName("*");
              int i2 = nl1.getLength();
              System.out.println(i2);
              for(int i=0; i<i2; i++) {
                   System.out.println(nl1.item(i) + "\n");
    }

  • How to read the contents of attached files

    Hi,
    I am designing a Form using LiveCycle Designer 8.0
    Scenario:
    User can attach the file through "Attachments" facility provided on Adobe  Reader.
    The requirement is to attach 3 documents and post it to SAP system using Web services.
    I am using the following code(which i got from this forum only) to find the number of files user has attached.
    d = event.target.dataObjects;
    n =  d.length;
    xfa.host.messageBox("Number  of Attachments: "+n);
    //Displaying  the names of the Attached files
    for( i =  0; i < n; i++ )
    xfa.host.messageBox("Name  of the file: "+d[i].name);
    My problem: is how to read the contents of the attached files so that I post it to SAP using Web services
    Thanks in advance!!
    Taha Ahmed

    In order to read the content of the Redo Log files, you should use Logminer Utility
    Please refer to the documentation for more information:
    [Using LogMiner to Analyze Redo Log Files|http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#SUTIL019]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Help me...How to read the content if "Transfer-Encoding:chunked" is used?

    I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.If the HTTP header contains Content-Length,am getting the content length as below:
    public class HTTPResponseReader extends HTTPMessageReader
        String statusCode;
        public HTTPResponseReader(InputStream istream) throws IOException,                     NoSuchElementException
      BufferedInputStream distream = new BufferedInputStream(istream);
      retrieveHeader(distream);
      StringTokenizer st =  new StringTokenizer(new String(HTTPMessageReader.toArray(header)));
      versionProtocol = st.nextToken();
      statusCode = st.nextToken();
      String s;
      while (st.hasMoreTokens())
            s = st.nextToken();
            if (s.equals("Transfer-Encoding:"))
           transferEncoding = new String(st.nextToken());
         if (s.equals("Content-Length:"))
           contentLength = Integer.parseInt(st.nextToken());
         if (s.equals("Connection:"))
          connection = new String(st.nextToken());
          if (connection.equals("keep-alive")) mustCloseConnection = false;
       retrieveBody(distream);     
    }After getting the Content-Length,i used read method to read the content upto that content length.Then i concatenated the HTTP header and body and the requested site was opened.But some sites dont have Content-Length.Instead of that,Transfer-Encoding is used.I got the HTTP Response header as "Transfer-Encoding:chunked" for some sites.If this encoding is used how to get the length of the message body and how to read the content.
    Can anybody help me.
    Thanks in advance...
    Message was edited by:
    VeeraLakshmi

    Why don't you use HttpUrlConnection class to retrieve data from HTTP server? This class already supports chunked encoding...
    If you want to do anything by yourself then you need to read HTTP RFC and find all required information. Well in two words you may reject advanced encoding by specifying HTTP 1.0 in your request or download chunked answer manually. Read RFC anyway :)

  • Can a search engine read the contents of a Library file embedded in a page?

    Can a search engine read the contents of a Library file
    embedded in a page? Or would SSI be the way to go. I'm creating a
    large library of text-based information and links, and I want to
    have much of it modular so I can add a link and all the many pages
    on my site updates to reflect the change. A big concern is that
    when a search engine visits my site, can it read the content
    embedded in the library item, or is SSI a better method to help the
    search engine read my content?
    Thanks

    Yes, search engines can read Dreamweaver library items. The
    library only exists on your own hard drive. Once you add the
    library item to your pages it's in there as regular HTML.
    If you have more than 20 pages on your site, they say SSI is
    better, because when you update you only update the SSI. If you
    stick with library items each page has to be uploaded every time
    the library is updated.

Maybe you are looking for

  • Portege R100 - Random Blue Screen of Death (IRQL not less or equal)

    Hi, I've been getting random "Blue Screen of Death" screens in the last few weeks. The error is "IRQL not less or equal" and it's performing a memory dump every time. If I get the error and try restarting the laptop after, I usually get the same "Blu

  • Windows 7 Explorer Crashes every time. Anyone Help?

    Over the last 2 weeks I have been experiencing a very frustrating problem with Windows 7 Explorer.  Below is an excerpt of the message from the Event viewer: Event filter with query "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetIns

  • .rserv wants to connect to krymbrjasnof

    I recently had Little Snitch block ".rserv wants to connect to cuojshtbohnt.  Moments ago, I blocked another that said ".rserv wants to connect to krymbrjasnof." I searched my Launch Agent and computer for "rserv" but come up with nothing.  Since I h

  • Variable - select YY in MM-YY

    Hi I have a report to do, with differents ratios. I would like their name to be variable. So I use variable caracteristics witch allows to have title like 'Advertising budget 2005' rather than 'Advertising budget N'. But sometimes, the user has to se

  • Re: Business Objects ( xcelcius, universe,..)

    Hi experts, I am trying to get knowledge on BO. Can anyone give me path to know more about BO. I am hearing lot of application names like xcelcius, universe, crystal and so on. How can I can more clarity on this. regards, rajesh Edited by: Rajesh.biw