#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Scanner class problem


    uide.java:2: cannot resolve symbol
    symbol : class Scanner
    location: package util
    import java.util.Scanner;
    ^
    uide.java:9: cannot resolve symbol
    symbol : constructor FileInputStream ()
    location: class java.io.FileInputStream
    FileInputStream file = new FileInputStream();
    ^
    uide.java:54: open(java.lang.String) has private access in java.io.
    FileInputStream
    file.open(" F:\\abcd.txt");

    here is the source which is written

    import java.io.*;
    import java.util.Scanner;
    public class uide
    {
    public static void main(String args[])throws IOException
    {
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader input = new BufferedReader(reader);
    FileInputStream file = new FileInputStream();
    System.out.println("ENTER THE CORRESPONDING CHAPTER NO.");
    String q0 = input.readLine();
    System.out.println("");
    String q1 = input.readLine();
    int m9 = Integer.parseInt(q0);
    System.out.println('\f');
    if (m9==1)
    {
    System.out.println("");
    int m8 = Integer.parseInt(q1);
    if(m8==1)
    {
    System.out.println("define the question");
    System.out.println("");
    file.open(" F:\\abcd.txt");
    }
    }
    }
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    62
    Rep Power
    3

    Exclamation


    Java Code:
    import java.io.*;
    import java.util.Scanner;
    public class uide
    {
     public static void main(String args[])throws IOException
     {
         InputStreamReader reader = new InputStreamReader(System.in);
         BufferedReader input = new BufferedReader(reader);
         FileInputStream file = new FileInputStream();
         System.out.println("ENTER THE CORRESPONDING CHAPTER NO.");
         String q0 = input.readLine();
         System.out.println("");
         String q1 = input.readLine();
         int m9 = Integer.parseInt(q0);
         System.out.println('\f');
         if (m9==1)
         {
             System.out.println("");
             int m8 = Integer.parseInt(q1);
             if(m8==1)
             {
                 System.out.println("define the question");
                 System.out.println("");
                 file.open(" F:\\abcd.txt");
                }
            }
        }
    }

    Firstly, I can't see where you are using the Scanner? It seems to be an unused import. Secondly, please use the Highlight tag so that your code is lined up properly.

    Also, when you are dealing with file handling, you should always try and catch.

    Here is your code without errors - although I'm not saying it's going to be doing what you want it to... it just compiles okay:
    Java Code:
    import java.io.*;
    import java.util.Scanner;
    public class uide
    {
        public static void main(String args[])throws IOException
        {
            InputStreamReader reader = new InputStreamReader(System.in);
            BufferedReader input = new BufferedReader(reader);
            File file = new File("F://abcd.txt");
            FileInputStream fin = null;
            System.out.println("ENTER THE CORRESPONDING CHAPTER NO.");
            String q0 = input.readLine();
            System.out.println("");
            String q1 = input.readLine();
            int m9 = Integer.parseInt(q0);
            System.out.println('\f');
            if (m9==1)
            {
                System.out.println("");
                int m8 = Integer.parseInt(q1);
                if(m8==1)
                {
                    System.out.println("define the question");
                    System.out.println("");
                    fin = new FileInputStream("F://abcd.txt");
                }
            }
        }
    }

    It'd be an idea if you say exactly what you are trying to achieve, rather than randomly pasting code.

    Good luck though.

    Regards,

    Shaun.

IMN logo majestic logo threadwatch logo seochat tools logo