How to read the particular line in a file !!!

i want to read the 5th , 8th or some other line number of the file. This file is consists of many data arranged by line number. I'm able to retrieve the LineNumber of the file but i'm not able to point the curser to that particular line so it can read that line only.
i'm pointing the cursor to that particular linenumber as in.setLineNumber(5) it moves to that particular line but after that when i try to read that particular line i'm not able to read that line.
could any one tell me which is the other way to read that particular line or in this only where i'm doing wrong...
i need this urgent....

As is typical of people who claim their problem is urgent, you posted this in the wrong forum (it doesn't have anything to do with JSP) and you left out any details that might help us understand what you are blathering about.
So take a deep breath. It isn't urgent. There is no rush. Now formulate a proper description of your problem and post it in the proper forum.

Similar Messages

  • 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.

  • 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 last line in a txt file?

    Dear all,
    I want to read the last line in a txt file. There are thousands of lines in this file. What I want is to move the file pointer directly to the last line of the file. But I did not know how do to it. Can anybody help me out?
    Thank you very much!

    If the file is coded as ASCII or one of the encodings that maps a single byte to a char then the following class will assist you
    import java.io.*;
    import java.util.*;
    public class GetLinesFromEndOfFile
        static public class BackwardsFileInputStream extends InputStream
            public BackwardsFileInputStream(File file) throws IOException
                assert (file != null) && file.exists() && file.isFile() && file.canRead();
                raf = new RandomAccessFile(file, "r");
                currentPositionInFile = raf.length();
                currentPositionInBuffer = 0;
            public int read() throws IOException
                if (currentPositionInFile <= 0)
                    return -1;
                if (--currentPositionInBuffer < 0)
                    currentPositionInBuffer = buffer.length;
                    long startOfBlock = currentPositionInFile - buffer.length;
                    if (startOfBlock < 0)
                        currentPositionInBuffer = buffer.length + (int)startOfBlock;
                        startOfBlock = 0;
                    raf.seek(startOfBlock);
                    raf.readFully(buffer, 0, currentPositionInBuffer);
                    return read();
                currentPositionInFile--;
                return buffer[currentPositionInBuffer];
            public void close() throws IOException
                raf.close();
            private final byte[] buffer = new byte[4096];
            private final RandomAccessFile raf;
            private long currentPositionInFile;
            private int currentPositionInBuffer;
        public static List<String> head(File file, int numberOfLinesToRead) throws IOException
            return head(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> head(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert encoding != null;
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                lines.addLast(line);
            reader.close();
            return lines;
        public static List<String> tail(File file, int numberOfLinesToRead) throws IOException
            return tail(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> tail(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert (encoding != null) && encoding.matches("(?i)(iso-8859|ascii|us-ascii).*");
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new BackwardsFileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                // Reverse the order of the characters in the string
                char[] chars = line.toCharArray();
                for (int j = 0, k = chars.length - 1; j < k ; j++, k--)
                    char temp = chars[j];
                    chars[j] = chars[k];
                    chars[k]= temp;
                lines.addFirst(new String(chars));
            reader.close();
            return lines;
        public static void main(String[] args)
            try
                File file = new File("/usr/share/dict/words");
                int n = 10;
                    System.out.println("Head of " + file);
                    int index = 0;
                    for (String line : head(file, n))
                        System.out.println(++index + "\t[" + line + "]");
                    System.out.println("Tail of " + file);
                    int index = 0;
                    for (String line : tail(file, "us-ascii", n))
                        System.out.println(++index + "\t[" + line + "]");
            catch (Exception e)
                e.printStackTrace();
    }Note, the EOL characters are treated as line separators so you will probably need to read the last two lines (think about it for a bit).

  • How to read the second line in a .txt file with bufferedReader?

    hi,
    i am not the best in speaking english and programming java :)
    so, just try to make sense of my question:
    Im using a BufferedReader to read a .txt file.
    the .txt file has 5+ different lines, and each line has 6 tokens (separated with ; )
    My java file has 6 textFields and each textfield is filled with one of the 6 different tokens.
    and my problem is:
    I want my buffered reader to read the next line (with 6 new different tokens) by pressing a button.
    if somethings not understandable, just ask :)

    maybe its easier to help me, when i publish my code, so here it is:
    (its my version, without Thof's code. Sorry, but the comments are the most in german)
    /* userdata.java */
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    public class userdata extends Frame {
    //-----------------------------------KlassenVariablen------------------------------------------------
    private JPanel panel = new JPanel ();
    String tokId = "";
    String tokName= "";
    String tokAge= "";
    String tokTel= "";
    String tokMail= "";
    String tokText= "";
    BufferedReader br;
    String zeile;
    StringTokenizer st;
    String delim = ";";
    //---------Buttons f?r Panel 1-------------------------
    Button first = new Button("|< First");
    Button back = new Button("< Back");
    Button next = new Button("Next >");
    Button last = new Button("Last >|");
    //---------Buttons f?r Panel 3-------------------------
    Button neu = new Button("New");
    Button safe = new Button("Safe");
    Button refresh = new Button("Refresh");
    //--------Labels f?r Panel 2-----------------------------
    Label lid = new Label("ID",Label.LEFT);
    Label lname = new Label("Name",Label.LEFT);
    Label lage = new Label("Age",Label.LEFT);
    Label ltel = new Label("Tel.",Label.LEFT);
    Label lmail = new Label("E-Mail",Label.LEFT);
    Label ltext = new Label("Spruch",Label.LEFT);
    Label lub = new Label("Last Button",Label.LEFT);
    TextField id = new TextField();
    TextField name = new TextField();
    TextField age = new TextField();
    TextField tel = new TextField();
    TextField mail = new TextField();
    TextField text = new TextField();
    TextField usedbutton = new TextField();
    //--------ActionEvent bla sachen eben--------------------
    public static void main (String[] args) throws IOException {
    userdata wnd = new userdata();
    wnd.setVisible(true);
    public userdata() throws IOException {                                                                                                                                                                                                                                                                                
    //--------------------------------Layout mit panel bestimmung--------------------------------------
    setLayout(new BorderLayout());
    JPanel p1 = new JPanel();
    JPanel p2 = new JPanel();
    JPanel p3 = new JPanel();
    add(BorderLayout.NORTH ,p1);
    add(BorderLayout.CENTER , p2);
    add(BorderLayout.SOUTH , p3);
    //-------------------------------Funktionslose Buttons in PANEL 1------------------------------------
    p1.add(first);
    p1.add(back);
    p1.add(next);
    p1.add(last);
    p1.add(usedbutton);
    //--------------------------------Funktionierende Textfelder in PANEL 2------------------------------
    Panel labelpanel = new Panel();
    p2.setLayout(new GridLayout(7,3));
    p2.add(lid);
    p2.add(id);
    p2.add(lname);
    p2.add(name);
    p2.add(lage);
    p2.add(age);
    p2.add(ltel);
    p2.add(tel);
    p2.add(lmail);
    p2.add(mail);
    p2.add(ltext);
    p2.add(text);
    p2.add(lub);
    p2.add(usedbutton);
    //--------------------------------------Buttons in PANEL 3-----------------------------------------
    p3.add(neu);
    p3.add(safe);
    p3.add(refresh);
    //--------------------------------BufferedReader -------------------------------------------------
    readData();
    //--------------------------------Panel 2 TextField-----------------------------------------------
    fillForm();
    //================================ActionPerformed==================================================
    first.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    System.out.println ("First");
    usedbutton.setText("First");
    back.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    System.out.println ("Back");
    usedbutton.setText("Back");
    next.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    System.out.println ("Next");
    usedbutton.setText("Next");
    last.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    System.out.println ("Last");
    usedbutton.setText("Last");
    neu.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    System.out.println ("New entry");
    usedbutton.setText("New");
    safe.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    System.out.println ("Now Saving, do not turn off!");
    usedbutton.setText("Save");
    //-----------------refresh
    refresh.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed( ActionEvent e ) {
    try{
    readData();
    }catch( IOException ioe){
    System.out.println("Fehler beim lesen aus Datei");
    fillForm();
    usedbutton.setText("Refresh");
    //=============================================================================Button Funktionen!!!
    pack();
    //--------------------------------WindowsListener hinzuf?gene--------------------------------------
    addWindowListener(
    new WindowAdapter() {
    public void windowClosing(WindowEvent event)
    setVisible(false);
    dispose();
    System.exit(0);
    //-----------------------------------readData() - > Buffered Reader in aktion! --------------------
    private void readData() throws IOException{
    BufferedReader br = new BufferedReader(new FileReader("My .txt File with path"));
    String zeile;
    StringTokenizer st;
    String delim = ";";
    zeile = br.readLine();
    st = new StringTokenizer(zeile, delim);
    st.hasMoreTokens();
    //System.out.println (st.nextToken());
    tokId = new String(st.nextToken());
    tokName = new String (st.nextToken());
    tokAge = new String (st.nextToken());
    tokTel = new String (st.nextToken());
    tokMail = new String (st.nextToken());
    tokText = new String (st.nextToken());
    //--------------------------fillForm() - > f?llt die TextFelder aus!--------------------------------
    private void fillForm(){
    id.setText(tokId);
    name.setText(tokName);
    age.setText(tokAge);
    tel.setText(tokTel);
    mail.setText(tokMail);
    text.setText(tokText);
    }

  • How to read the last line in a text file using text_io?? please help

    Dear all
    I made a procedure that append text into a text file on the operating system.
    the text file grows rapidly. It contains now about 200,000 line . I need to read the last line only . In other wprds i need to go direct to the last line to read some values. Is it possible??
    Please help

    Hello,
    If you know the number of the line you want to read, I can sugget you to use the MORE dos command or the TAIL unix command that redirect to a temporary text file
    Example to create a file that contains the 200010th last lines :
    (Client)Host( 'MORE the_file_name.txt +200010 > small_file.txt') ;So you have only to read the small file with the TEXT_IO functions.
    Francois

  • How to read the contens of an ini-File

    How can I read the contens of an ini-File?

    Depends on what you have in the file - ini file with or without sections.
    Without sections: you may be able to read it as a property file.
    With sections: You'll have to implement a class to read and parse the file, and a class to hold the parsed results.
    If you have to build your own objects, I found the easiest way was to read each line and use the StringParser to pick it apart. My data holding object was pretty simple -
    o A Vector to hold Section objects.
    o A Section object with a Vector to hold each Entry object.
    o An Entry object
    o Appropriate getters and setters to look up stuff I wanted or to insert it.
    My model for the object was the Borland C++ IniFile object, but I separated the I/O so that I could read or write from any stream I wished, including just a long string.
    o an internal object for section, an internal object for entry

  • 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 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

  • How to read the particular row in table..

    HELLO ALL
    I have a dynamically generated table which is filled with values
    from a Bean. The next step is to select a row in that table by
    clicking on a check box. The problem is that i want to read 3
    values from the selected row. I can get the value from the checkbox
    button but i always get the values from the first line in the
    table. Is there someway to select an entire row and submit in in
    the request so i can read the values from the selected row?

    Yes,
    but the checkbox values are printing rightly.I mean if user checks 1,5 rowed checkbox in next jsp printing 1 and 3.But the rowed values are printing sequence manner,not the chcked ones.

  • How to read the tail of a large file?

    My application writes to a log file. I want to read the end (say last 100 lines) of the logfile and display it on a web page. I dont want to read the entire log file as everything apart from the last 100 lines is irrelevant. Is there a way to do this? The only thing i can think of is to do this on a linux command prompt "tail logfile.txt > storehere.txt " and then read storehere.txt. Not ideal. Is there a way i can read the last 100 lines or better still have a continous stream of the last 100 lines of the log file?

    This question has been ask here before; but, I am not sure that a good solution was found.
    Assuming the file does not have fixed length records (then it would be easy), the only thing I can think of is:
    Use RandomAccessFile to read the bytes in the file backwards and store them until you have processed 100 lines. In reality, you would probably not want to read one byte at a time but read "chucks" of the file into a buffer and process those bytes. Similar to how BufferedInputStream works only getting the bytes in reverse order.
    I.E.
    Create a class that returns a byte of the file in reverse order. This class would fill a buffer with a chuck as needed.
    One big issue with this idea is if you are reading Unicode characters - multiple bytes would need to be consumed to pass back a character and since not all Unicode characters are 2-bytes, this could get messy.

  • 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 'date modified' of a file?

    I need to read the date that a file was modified so I can see
    if it has been updated. The file is just a text file in the same
    directory as my swf file.
    I tried using FLfile.getModificationDate, but it doesn't seem
    to work. Every way I write the code, I get no response. It does not
    seem to find the file. I even tried using the FLfile.write as a
    test, without luck. I searched and the FLfile.dll is on my machine,
    but I wonder if I have to somehow let the flash file know its
    there.
    I also tried using FileReference.modificationDate, but from
    what I have come to understand, I need to populate the
    FileReference object and that populating the FileReference object
    involves uploading or downloading the file. I'm not up or
    downloading the file, I just need to know if it has been updated by
    other software. Otherwise, how do I populate the FileReference
    object. Can it check on dates without up or downloading?
    Does anyone have an idea of the best way to read the date
    that the file was modified?
    Thank you.

    quote:
    Originally posted by:
    Point Happy
    I searched and the FLfile.dll is on my machine, but I wonder
    if I have to somehow let the flash file know its there.
    quite right, you need to create a Project (and a JavaScript
    file)
    then you can use the JavaScript that you want to use

  • How to read the extended-cache-config.xml file. in C++ API

    I want to create my own XML config file and define the config values in that, so that C++ Client (using Coherence C++ API) application can access the config files.
    Also how to get the instance of configuration values which Coherence client has read,
    i.e.
    TangosolCoherenceOverride=$PATH/examples/config/tangosol-coherence-override.xml
    TangosolCoherenceCacheconfig=$PATH/examples/config/extend-cache-config.xml
    How to get the instance of this XMLDocument ? and read values from it.
    Thanks,
    Naveen

    Hi,
    You can get the cache-config that was read by getting it from the ConfigurableCacheFatory (which you can get from the CacheFactory) via getConfig(). See:
    http://download.oracle.com/otn_hosted_doc/coherence/352CPP/classcoherence_1_1net_1_1_cache_factory.html
    http://download.oracle.com/otn_hosted_doc/coherence/352CPP/classcoherence_1_1net_1_1_configurable_cache_factory.html
    There is no way to get the actual XmlDocument object from the cluster that is read for the cluster-config (though you could open the same path yourself).
    thanks,
    -Rob

  • How to read the data in a txt file on a web site?

    I want to extract the numbers located in txt files on a web site. It's a normal url. Not a ftp.
    Does anyone know how to do it?

    Hi Tom,
    What do you want to extract from the text file??
    I wanted to extract an IP address from a pearl script from my FTP server and this was the vi that I used .I dont know if you are trying to do the same?
    Here is the vi.It is in LV 7.1
    Hope its helps .
    Good luck.
    ohiofudu.
    Certified LabVIEW Architect
    Certified TestStand Developer
    Attachments:
    PublicIP-Adresse.vi ‏31 KB

Maybe you are looking for

  • Can I use the "same" button multiple times for multiple galleries?

    OK so I am extremely untrained in CS4 and Actionscript. However I have managed to get along fairly well until I started to dynamically upload images as a gallery. This works great if I have one gallery, but for my site I have 9 galleries!!! I have a

  • Error in BAPI_SALESORDER_CREATEFROMDAT2 to create sales order

    Hi all, I'm trying to create a sales order using bapi_salesorder_createfromdat2. I have given the import parameters as per the documentation. But i'm getting the following error messages from the return parameter number       message   233          

  • Is there any A/B testing setup code in dreamweaver?

    I am trying to setup A/B testing.  I am not a coder but I know there are solutions in Wordpress.  How do you setup A/B testing using php code?

  • Remove cancelled appointment

    I have 2 calendars I sync with my iPhone, Exchange 2010 and Google Calendar. Whenever I receive a meeting invitation on my google calendar I can't edit the appointment at all, in fact the edit button is not there. The meeting shows up surrounded by a

  • Production costs full absorption

    Hi, I have few service cost centers and production cost centers. At the month end we are allocation service cost centers expenses to production cost centers using various statistical key figures. At the month end we want to absorb full cost in produc