Results 1 to 2 of 2

Thread: read file

  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default read file

    hey every body

    Java Code:
     public void readSura() {
            sNumber = jComboBox1.getSelectedIndex();
            jTextArea1.setText(null);
            System.out.print(sNumber);
            file = new File("qu/" + sNumber);
            try {
                input = new Scanner(file);
            } catch (FileNotFoundException ex) {
                JOptionPane.showMessageDialog(null, "can't fine file", "error", JOptionPane.ERROR_MESSAGE);
            }
            while (input.hasNextLine()  && noOfLines < 10) { //read first 10 lines fro file
                String outPut = input.nextLine();
                jTextArea1.append(outPut+"\n\n");
                ++ noOfLines;
    
            }
    
            input.close();
        }
    this code is the action of JButton , this read the first 10 lines
    i want if a press on it again read the next 10 lines .... etc , plz i need help??

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Read a file and converting this file into a string
    By kostinio in forum New To Java
    Replies: 7
    Last Post: 12-26-2009, 03:54 PM
  2. Replies: 2
    Last Post: 05-11-2009, 10:07 AM
  3. Replies: 0
    Last Post: 02-11-2009, 09:53 AM
  4. Replies: 5
    Last Post: 02-05-2009, 10:28 AM
  5. How to read a text file from a Java Archive File
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-08-2008, 09:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •