Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How do I use CinReader?

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do I use CinReader?

    I'm new to CinReader. I've imported it and everything, but I'm lost on how to use it.

    class ExamEngine {
        static CinReader Cin= new CinReader();
        public static void main(String[] args) {
            System.out.println("What's your name?");
            String spelling=Cin.nextLine();
        }
    }

    It says cannot find symbol- method nextLine();

    This is how I did it with the scanner and it worked fine.

    import java.util.Scanner;
    class Player {
        public static void main(String[] args) {
            Scanner scanner1 = new Scanner(System.in);
    System.out.println("What is your name?");
    String Playername=scanner1.nextLine();
    }
    }

    What am I doing wrong with CinReader
    Last edited by DarkestLord; March 11th, 2014 at 04:02 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,381
    Thanks
    49
    Thanked 2,208 Times in 2,181 Posts

    Default Re: How do I use CinReader?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    What package is CinReader in? Is there some API doc for it? If so, have you read it?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How do I use CinReader?

    Mmmm...not sure what you mean by "package". I just downloaded it and I can use it for integers just fine, but I haven't been able to type words into it.
    Last edited by DarkestLord; March 11th, 2014 at 04:15 PM.

  4. #4
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: How do I use CinReader?

    Take a look at the CinReader API docs at Generated Documentation (Untitled). CinReader does not have a nextLine method.

    Since the API docs are devoid of examples, here's one showing how you would use it to get an integer input:

        public static void main(String[] args) {
            CinReader reader = new CinReader();
            System.out.println("Enter integer: ");
            int response = reader.readInt();
     
            System.out.println("response: " + response);
        }

    As for the code to read String values, well, that's the exercise for you. :-)