List of usage examples for java.util Scanner next
public String next()
From source file:com.envirover.spl.SPLGroundControl.java
public static void main(String[] args) { try {/*from w w w . ja v a 2s. c o m*/ SPLDaemon daemon = new SPLDaemon(); daemon.init(new SPLDaemonContext(args)); daemon.start(); System.out.println("Enter 'stop' to exit the program."); Scanner scanner = new Scanner(System.in); String str; while (!(str = scanner.next()).equalsIgnoreCase("stop")) { //Just echo the user input for now. System.out.println(str); } System.out.println("Exiting..."); scanner.close(); daemon.stop(); daemon.destroy(); System.out.println("Done."); System.exit(0); } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:cit360.sandbox.CIT360SandBox.java
public static void main(String[] args) throws Exception { Scanner input = new Scanner(System.in); System.out.println("What is your name?"); CIT360SandBox.firstName = input.next(); System.out.println("Welcome " + firstName + "!"); CIT360SandBox.App.mainMenu();/* w w w. jav a 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { char[][] original = new char[3][3]; Scanner s = new Scanner(System.in); System.out.println("Enter values: "); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { original[i][j] = s.next().charAt(0); }/*from w ww . j a v a 2s . c o m*/ } rotate(original); }
From source file:org.tamilunicodeconverter.Main.java
public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); // source file System.out.println("Enter the source file or directory: "); String sourceFilePath = keyboard.next(); // output dir System.out.println("Enter the output directory: "); String outputDir = keyboard.next(); // auto create file names System.out.println("Automatically create output file names based on content? (True|False): "); boolean createOutputFileName = keyboard.nextBoolean(); if (StringUtils.isNotBlank(sourceFilePath) && StringUtils.isNotBlank(outputDir)) { new TamilUnicodeConverter(createOutputFileName).convert(new File(sourceFilePath), new File(outputDir)); } else {//from w w w . jav a 2s. c o m System.out.println("Both source and output dir are mandatory. Please run the program again."); } }
From source file:ScanXan.java
public static void main(String[] args) throws IOException { Scanner s = null; try {/*w ww.j a va 2s . c om*/ s = new Scanner(new BufferedReader(new FileReader("xanadu.txt"))); while (s.hasNext()) { System.out.println(s.next()); } } finally { if (s != null) { s.close(); } } }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0 "; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is an int System.out.println(scanner.hasNextInt()); System.out.println(scanner.next()); }/*from w ww . j a va 2 s. c o m*/ scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is a byte System.out.println(scanner.hasNextByte()); System.out.println(scanner.next()); }/*from www.j a v a 2 s. c o m*/ scanner.close(); }
From source file:org.trafodion.rest.zookeeper.ZkUtil.java
public static void main(String[] args) throws Exception { if (args.length < 1) { System.err.println("Usage: ZkUtil {command}"); System.exit(1);/*from www. ja va2 s .c o m*/ } Options opt = new Options(); CommandLine cmd = null; try { cmd = new GnuParser().parse(opt, args); } catch (NullPointerException e) { System.err.println("No args found: " + e); System.exit(1); } catch (ParseException e) { System.err.println("Could not parse: " + e); System.exit(1); } try { String znode = cmd.getArgList().get(0).toString(); ZkClient zkc = new ZkClient(); zkc.connect(); Stat stat = zkc.exists(znode, false); if (stat == null) { System.out.println(""); } else { List<String> znodes = zkc.getChildren(znode, null); zkc.close(); if (znodes.isEmpty()) { System.out.println(""); } else { Scanner scn = new Scanner(znodes.get(0)); scn.useDelimiter(":"); String hostName = scn.next();//host name scn.close(); System.out.println(hostName); } } } catch (Exception e) { System.err.println(e); e.printStackTrace(); System.exit(1); } }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com false 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is a boolean System.out.println(scanner.hasNextBoolean()); System.out.println(scanner.next()); }//ww w. j ava 2s . c o m scanner.close(); }
From source file:Main.java
public static void main(String[] args) { String s = "java2s.com 1 + 1 = 2.0"; Scanner scanner = new Scanner(s); while (scanner.hasNext()) { // check if the scanner's next token is a BigInteger System.out.println(scanner.hasNextBigInteger()); System.out.println(scanner.next()); }//from w w w. ja v a 2 s .c o m scanner.close(); }