scanner « string « Java Data Type Q&A





1. Java Scanner class reading strings    stackoverflow.com

I got the following code:

     int nnames;
 String names[];

 System.out.print("How many names are you going to save: ");
 Scanner in = new Scanner(System.in);
 nnames = in.nextInt();
 names ...

2. Java Scanner class reading strings    stackoverflow.com

I got the following code:

int nnames;
    String names[];

    System.out.print("How many names are you going to save: ");
    Scanner in = new Scanner(System.in);
 ...

3. Java Scanner class reading strings    stackoverflow.com

I've created a scanner class to read through the text file and get the value what I'm after. Let's assume that I have a text file contains.

List of people: ...

4. Problem with java.util.Scanner & strings    stackoverflow.com

I tried to implement a simple yes/no input with java.util.Scanner. My code looks like this:

public boolean ask(String quest){
  String answ = scann(quest + " (y/n)");
  answ = answ.split("")[1].toLowerCase();
  ...

5. Using string taken from Scanner not working?    stackoverflow.com

When I run the program and enter a rank & gender it yells at me and tells me it is an invalid gender. I cannot see why if I enter "male" ...

6. How to answer a question with a string using the scanner class using java?    stackoverflow.com

I have been trying all weekend to find a way to get my program to answer a question using a sting with a scanner class. For example I need to get ...

7. How to save a String in local buffer so that it can be re-read by Scanner?    stackoverflow.com

I am working on some project which deals with HTML pages. I don't want to download the same page over and over again, so I want to save it locally. I use the ...

8. cannot find symbol -- symbol : method lastIndexOf(java.lang.String) location: class java.util.Scanner    stackoverflow.com

My code tries to extract a filename to load a file from reading another file that contains the filename:

public static void main(String[] args) throws IOException
{
    Scanner scan;
  ...

9. Java Scanner String input    stackoverflow.com

I'm writing a program that uses an Event class, which has in it an instance of a calendar, and a description of type String. The method to create an event ...





10. How to read carriage-returns as part of String with Scanner?    stackoverflow.com

I'm writing a java program that will require a long String as input from the user. Most of these Strings are news articles copied and pasted off the internet. ...

11. Java String Scanner input does not wait for info, moves directly to next statement. How to wait for info?    stackoverflow.com

I am writing a simple program that prompts a user to enter a number of students, then asks the user to enter each student's name and score in order to determine ...

12. Reading strings with Scanner class    coderanch.com

Hi everyone, Java noob here. I'm wondering if there is any way to read String inputs from the user with the Scanner class? From my readings there does not seem to be a way and if that is the case what utility can I use to do this? I basically just want to read each character from a users inputted string. ...

13. how to accept \ (backslash) in a string when using Scanner.    coderanch.com

ok i want to make a very easy user interface for the client. there is a section where they would have to add the path to a file. its targeted at windows users so lets say they need to specify this path c:\ program files\Counterstrike\new map" im making a file in the directory however i would like it if i could ...

14. Can i use Java Scanner with String?    java-forums.org

15. Scanner class with a String    java-forums.org

Java Code: import java.util.*; public class TestTriangle { public static void main(String[] args) { Scanner input = new Scanner(System.in); double side1, side2, side3; boolean filled; String color; System.out.print("Enter Length of side 1 = "); side1 = input.nextDouble(); System.out.print("Enter Length of side 2 = "); side2 = input.nextDouble(); System.out.print("Enter Length of side 3 = "); side3 = input.nextDouble(); System.out.println("Enter the Color: "); ...

16. Strings made by scanner don't work with startsWith() method    java-forums.org

File output = new File("JavaOutput.txt"); System.out.println(output.exists()); PrintWriter outputWriter = new PrintWriter(output); for (int i = 140, j = 0; i < 160; i++, j++) { if (((File) arraySchem.get(j)).exists()) { Scanner newScanner = new Scanner((File) arraySchem.get(j)); while (newScanner.hasNextLine()) { String s = newScanner.nextLine(); outputWriter.println(s); outputWriter.println(); [B]if (s.startsWith("***")) { System.out.println("if working"); }[/B] } newScanner.close(); }





17. Simple string add or subtract using scanner    java-forums.org

ok I managed to get this working correctly. The code is to take in a string such as "345 + 456 + 5654 + 3434" and add the numbers, this seems to be working. However what I am trying to change it to also allow subtraction including checking the first number for a + or - sign. I have tried many ...

19. how to use Scanner to scan a String    java-forums.org

20. converting the scanner object into string object....    forums.oracle.com

Hello everyone. I've finished my hw and one thing made me curious about it. I hope you can help me. Now, I've tried to make this code in NetBeans IDE 6.0: Scanner src = new Scanner(System.in); String s = src.toString().toLowerCase(Turkish /* locale thing*/); My purpose is to take users entries to console as string and than make the letters in lower ...

21. Strings, regexes, and scanner    forums.oracle.com

Define abuse. Yep, There's the back edge of the professors sword. In your case, Does using Integer.parseInt()'s propensity for throwing NumberFormatException's when it can't convert it's input into the required output constitute abuse? I think not. Yep, you could spend days working up a nasty complex incomprehensible unfathomable unmaintainable (keep out of reach of children) set of regex's (it can't be ...

22. the string version of a scanner.nextInt    forums.oracle.com

Well.. yes i'm really new to jave Let's say something more cause i think i'm being a bit unclear... there is an input, always with 6 numbers and one lettercode 23 43 23 2 34 3 AA (in some cases there is an adition number, afther the lettercode ( # # # # # # AA #) The possible lettercodes are ...

24. Scanner to String problem. It seems like i can't convert the input to a str    forums.oracle.com

1) You never told us what error you were getting. 2) Your commented out code and you getInput() method do different things. Take a look at what the variables "one" and "two" are both cases. I think you will see that given the same inputs they are not the same in both cases. (I mean that the value of "one" is ...

25. Changing a scanner to a string?    forums.oracle.com

27. Problem with "if" statements using "string" generated by "scanner"    forums.oracle.com

Simply put, I can't get a boolean involving a scanner object to return true. For example, Scanner scanner = new Scanner("1 2 3 4 5"); String str = ""; while (scanner.hasNext()){ str = scanner.next(); System.out.print(str); } has a printout that looks like: 12345 However, if I add an "if" statement, like: Scanner scanner = new Scanner("1 2 3 4 5"); String ...

28. Scanner string input?    forums.oracle.com

30. Regarding reading in of numeric data in Scanner, followed by a String    forums.oracle.com

I am a student, new to Java and will be picking it up in the next semester in college. I've been doing my self-study using online tutorials and noticed that when I do this: Scanner input = new Scanner(System.in); System.out.print("Enter a number: "); try { double d = input.nextDouble(); System.out.println("The number is: " + d); System.out.print("Enter a number: "); String s ...