Package java.util

Examples of java.util.Scanner.nextLong()


      myFile = new Scanner(new FileInputStream(f));
      int i = 0; //this will be our local array index
      System.out.println("\nCreating a temporary array from file " + f.getName() + " with " + n + " records.");
      while (myFile.hasNextLine()) { //to check for EOF
        //fill up our array
        a[i] = new Warship(myFile.nextLong(), myFile.next(), myFile.nextInt(),
                myFile.next(), myFile.nextDouble(), myFile.nextInt());
        i++; //increment the index
      }
    } catch (FileNotFoundException e) {
      System.out.println("There was an error creating the Scanner object from file " + f.getName());
View Full Code Here


   
    //let's get the key in a try-catch block to catch any input mismatch mistakes
    while (!done){ //loop will help if there's an input mismatch exceptiony
      try{
        System.out.println("\nEnter the ship's serial number that you want to recall: ");
        searchKey = kb.nextLong();
        done = true; //break out of the asking loop
      } catch (InputMismatchException e){
        kb.nextLine(); //discard all the end of line scanner junkn
        System.out.println("\nThere was a problem capturing the number, please make sure " +
            " that you are entering a serial number. Try again.");
View Full Code Here

    String results = null;
    try {
      runCmd(shell, "-count", path);
      results = bytes.toString();
      in = new Scanner(results);
      assertEquals(dirs, in.nextLong());
      assertEquals(files, in.nextLong());
    } finally {
      if (in!=null) in.close();
      IOUtils.closeStream(out);
      System.setOut(oldOut);
View Full Code Here

    try {
      runCmd(shell, "-count", path);
      results = bytes.toString();
      in = new Scanner(results);
      assertEquals(dirs, in.nextLong());
      assertEquals(files, in.nextLong());
    } finally {
      if (in!=null) in.close();
      IOUtils.closeStream(out);
      System.setOut(oldOut);
      System.out.println("results:\n" + results);
View Full Code Here

        Scanner stringScanner = new Scanner(input);

        //Long Value
        if (stringScanner.hasNextLong())
        {
          Long id = stringScanner.nextLong();

          //Positive Number
          if (id > 0)
          {
            if (stringScanner.hasNext())
View Full Code Here

          System.out.println("Enter student info, id and last name " +
           "on one line separated by spaces:");
          Scanner stringScanner = new Scanner(scanner.nextLine());
          if (stringScanner.hasNextLong())
          {
            Long id = stringScanner.nextLong();

            if (id > 0)
            {
              if (stringScanner.hasNext())
              {
View Full Code Here

        Long result = null;

        if (value != null) {
            Scanner scanner = new Scanner(value);
            if (scanner.hasNextLong()) {
                result = scanner.nextLong();
            }
        }
        return result;
    }
}
View Full Code Here

    String results = null;
    try {
      new Count(new String[]{path}, 0, conf).runAll();
      results = bytes.toString();
      in = new Scanner(results);
      assertEquals(dirs, in.nextLong());
      assertEquals(files, in.nextLong());
    } finally {
      if (in!=null) in.close();
      IOUtils.closeStream(out);
      System.setOut(oldOut);
View Full Code Here

    try {
      new Count(new String[]{path}, 0, conf).runAll();
      results = bytes.toString();
      in = new Scanner(results);
      assertEquals(dirs, in.nextLong());
      assertEquals(files, in.nextLong());
    } finally {
      if (in!=null) in.close();
      IOUtils.closeStream(out);
      System.setOut(oldOut);
      System.out.println("results:\n" + results);
View Full Code Here

  public static void main(String[] args) {
    initPrimeTable();
   
    Scanner cin = new Scanner(System.in);
    while (cin.hasNext()) {
      long p = cin.nextLong();
      long a = cin.nextLong();
      if (p == 0 || a  == 0) {
        break;
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.