i need a guide to use Java Scanner class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kidosai
    New Member
    • Jan 2008
    • 2

    i need a guide to use Java Scanner class

    hi i need a guide on how to use the scanner class... i need to use Java Scanner class to read a text file and be able to print the text inside of it...

    example :

    i have a text file named "myFile.tex t"

    inside of it there are text writen or listed on it...

    Alvin
    Simon
    Dennes

    now... my problem is... how can i use the scanner to read the text file and be able to print those names?

    all i need is a guide...
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by kidosai
    hi i need a guide on how to use the scanner class... i need to use Java Scanner class to read a text file and be able to print the text inside of it...

    example :

    i have a text file named "myFile.tex t"

    inside of it there are text writen or listed on it...

    Alvin
    Simon
    Dennes

    now... my problem is... how can i use the scanner to read the text file and be able to print those names?

    all i need is a guide...
    Read this and this.

    Comment

    • kidosai
      New Member
      • Jan 2008
      • 2

      #3
      Originally posted by r035198x
      Read this and this.
      pls check my code if i have error... im having a error cant find symbol...

      import java.util.*;
      import javax.swing.*;
      public class Struck{
      public static void main(String args[]){
      String Jop=JOptionPane .showInputDialo g(null,"Input File Name: ");
      Scanner scan=new Scanner(new File("Jop"));
      while(scan.hasN ext()){
      System.out.prin tln(scan.next() );}
      }
      }

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by kidosai
        pls check my code if i have error... im having a error cant find symbol...

        import java.util.*;
        import javax.swing.*;
        public class Struck{
        public static void main(String args[]){
        String Jop=JOptionPane .showInputDialo g(null,"Input File Name: ");
        Scanner scan=new Scanner(new File("Jop"));
        while(scan.hasN ext()){
        System.out.prin tln(scan.next() );}
        }
        }
        1.) Use code tags when posting code.
        2.) Read the links that I posted above. The second one shows you how to read a file using two methods.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by kidosai
          pls check my code if i have error... im having a error cant find symbol...
          I'm sure you noticed that the compiler told you *what* symbol it can't find and on
          *which* line it discovered this trouble; why didn't you transfer that information to
          us? Do you want us to guess?

          kind regards,

          Jos

          Comment

          • PRIYAJESSI
            New Member
            • Feb 2008
            • 1

            #6
            Originally posted by kidosai
            hi i need a guide on how to use the scanner class... i need to use Java Scanner class to read a text file and be able to print the text inside of it...

            example :

            i have a text file named "myFile.tex t"

            inside of it there are text writen or listed on it...

            Alvin
            Simon
            Dennes

            now... my problem is... how can i use the scanner to read the text file and be able to print those names?

            all i need is a guide...
            i DON KNOW HOW TO DO THE USER INPUT IN JAVA?so tell me how to do it in programs?

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by PRIYAJESSI
              i DON KNOW HOW TO DO THE USER INPUT IN JAVA?so tell me how to do it in programs?
              Read the replies in this thread.

              Comment

              • sreekandank
                New Member
                • Jun 2009
                • 45

                #8
                Refer the URL : http://bytes.com/topic/java/insights...-scanner-class
                It will be more useful to you.

                Comment

                Working...