Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Zwander

Thread: I Need Some Help Finding the Error, I'm a 1-week Beginner...

  1. #1
    Ark3 is offline Member
    Join Date
    Jun 2014
    Posts
    59
    Rep Power
    0

    Default I Need Some Help Finding the Error, I'm a 1-week Beginner...

    So I was making another Program and this is what happens:

    I Need Some Help Finding the Error, I'm a 1-week Beginner...-error23.png

    The Code is here, Please tell me what to do, and what to type.

    Java Code:
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.InputStreamReader;
    import java.io.PrintStream;
     
     
    public class File_Read {
        public File_Read() {    
        newFile = new File(Input);
        iSR = new InputStreamReader(System.in);
        bRead = new BufferedReader(iSR);
        }
        public void Out(String a) {
            this.action(a);
        }
        public String inputRead(String a) throws Exception {
            this.action(a);
            return bRead.readLine();    
        }
        public void createF (String a) throws Exception {
            //Stuck Here!!
            String  Input;
            this.action(a);
            System.out.flush();
            Input = bRead.readLine();
            Input = "C:/Samuel/"+Input;
            newFile = new File(Input);
        }
        public void read (String a) throws Exception {
            String result = inputRead("1. 1 + 1 = ?");
            if (result.equals("2")) {
                FileOutputStream        fos = new FileOutputStream (newFile);
                PrintStream             ps = new PrintStream (fos);
                ps.println("Correct");
                System.out.flush();
            }if (!result.equals("2")) {
                FileOutputStream        fos = new FileOutputStream (newFile);
                PrintStream             ps = new PrintStream (fos);
                ps.println("Incorrect");
                System.out.flush();
            }   
             
            String result2 = inputRead("1. 3 + 1 = ?");
            if (result2.equals("4")) {  
                FileOutputStream        fos = new FileOutputStream (newFile);
                PrintStream             ps = new PrintStream (fos);
                ps.println("Correct");
                System.out.flush();
            }if (!result2.equals("4")) {
                FileOutputStream        fos = new FileOutputStream (newFile);
                PrintStream             ps = new PrintStream (fos);
                ps.println("Incorrect");
                System.out.flush();
            }   
             
            String result3 = inputRead("1. 8 + 1 = ?");
            if (result3.equals("9")) {  
                FileOutputStream        fos = new FileOutputStream (newFile);
                PrintStream             ps = new PrintStream (fos);
                ps.println("Correct");
                System.out.flush();
            }if (!result3.equals("9")) {
                FileOutputStream        fos = new FileOutputStream (newFile);
                PrintStream             ps = new PrintStream (fos);
                ps.println("Incorrect");
                System.out.flush();
            }
            }
        public void action (String a) {
            System.out.println(a);
            System.out.flush();
        }
        private File newFile;
        private String  Input;
        private InputStreamReader iSR;
        private BufferedReader bRead;
    }
    GODLIKE!!!!

  2. #2
    Zwander is offline Member
    Join Date
    Aug 2012
    Posts
    9
    Rep Power
    0

    Default Re: I Need Some Help Finding the Error, I'm a 1-week Beginner...

    Stack trace says there is an error initiating File at line 10.
    Line 10 is
    Java Code:
    newFile = new File(Input);
    You haven't assigned 'Input'.
    Ark3 likes this.

  3. #3
    Ark3 is offline Member
    Join Date
    Jun 2014
    Posts
    59
    Rep Power
    0

    Default Re: I Need Some Help Finding the Error, I'm a 1-week Beginner...

    Thanks
    GODLIKE!!!!

Similar Threads

  1. Beginner Error
    By BigBlueBuffalo in forum New To Java
    Replies: 1
    Last Post: 04-04-2013, 08:14 AM
  2. Help for finding out of error in this code
    By brk35 in forum New To Java
    Replies: 3
    Last Post: 02-27-2012, 06:48 PM
  3. Replies: 2
    Last Post: 03-12-2011, 02:14 PM
  4. Need help finding error in code
    By BobTedmen in forum New To Java
    Replies: 3
    Last Post: 05-04-2010, 04:51 AM
  5. Help Finding Compiler error solution please
    By jamesr2b in forum New To Java
    Replies: 5
    Last Post: 04-30-2009, 06:07 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
  •