Examples of Scanner


Examples of java.util.Scanner

  {
    File outputDir = new File(outputPath);
    if(!outputDir.exists())
    {outputDir.mkdirs();}

    Scanner in = new Scanner(System.in);
    String samplePackageName = SampleLoader.class.getPackage().getName();
    while(true)
    {
      // Get the classes belonging to the current package!
      List<Class<?>> samplePackageClasses = Package.getClasses(
        samplePackageName,
        new String[]{it.stefanochizzolini.reflex.Class.getLocation(ClassName)} // Locations: current deployment unit only.
        );
      Collections.sort(
        samplePackageClasses,
        new Comparator<Class<?>>()
        {
          @Override
          public int compare(Class<?> arg0, Class<?> arg1)
          {return arg0.getSimpleName().compareTo(arg1.getSimpleName());}
        }
        );

      // Picking available samples...
      System.out.println("\nAvailable samples:");
      List<java.lang.Class<?>> sampleClasses = new ArrayList<java.lang.Class<?>>();
      for(Class<?> samplePackageClass : samplePackageClasses)
      {
        if(Sample.class.isAssignableFrom(samplePackageClass)
            && !Modifier.isAbstract(samplePackageClass.getModifiers()))
        {
          sampleClasses.add(samplePackageClass);
          System.out.println("[" + sampleClasses.indexOf(samplePackageClass) + "] " + samplePackageClass.getSimpleName());
        }
      }
      System.out.println("[" + QuitChoiceSymbol + "] (Quit)");

      // Getting the user's choice...
      Class<?> sampleClass = null;
      do
      {
        System.out.print("Please select a sample: ");
        try
        {
          String choice = in.nextLine();
          if(choice.toUpperCase().equals(QuitChoiceSymbol)) // Quit.
            return;

          sampleClass = sampleClasses.get(Integer.parseInt(choice));
        }
View Full Code Here

Examples of java.util.Scanner

  protected String promptChoice(
    String message
    )
  {
    System.out.print("\n" + message);
    Scanner in = new Scanner(System.in);
    try
    {return in.nextLine();}
    catch(Exception e)
    {return null;}
  }
View Full Code Here

Examples of java.util.Scanner

          (option.getKey().equals("") ? "ENTER" : "[" + option.getKey() + "]")
            + " " + option.getValue()
          );
    }
    System.out.print("Please select: ");
    Scanner in = new Scanner(System.in);
    try
    {return in.nextLine();}
    catch(Exception e)
    {return null;}
  }
View Full Code Here

Examples of java.util.Scanner

    String fileExtension,
    String listDescription,
    String inputDescription
    )
  {
    Scanner in = new Scanner(System.in);

    System.out.println("\n" + listDescription + ":");
    SampleResources resources = new SampleResources(new java.io.File(inputPath + java.io.File.separator + "pdf" + java.io.File.separator));

    // Get the list of available PDF files!
    List<String> filePaths = Arrays.asList(resources.filter(fileExtension));
    Collections.sort(filePaths);

    // Display files!
    resources.printList((String[])filePaths.toArray());

    // Get the user's choice!
    System.out.print(inputDescription + ": ");
    try
    {return inputPath + java.io.File.separator + "pdf" + java.io.File.separator + filePaths.get(Integer.parseInt(in.nextLine()));}
    catch(Exception e)
    {return inputPath + java.io.File.separator + "pdf" + java.io.File.separator + filePaths.get(0);}
  }
View Full Code Here

Examples of java.util.Scanner

  {
    System.out.println();
    SerializationModeEnum serializationMode = SerializationModeEnum.Incremental;
    if(chooseMode)
    {
      Scanner in = new Scanner(System.in);
      System.out.println("[0] Standard serialization");
      System.out.println("[1] Incremental update");
      // Get the user's choice.
      System.out.print("Please select a serialization mode: ");
      try
      {serializationMode = SerializationModeEnum.values()[Integer.parseInt(in.nextLine())];}
      catch(Exception e)
      {/* Default. */}
    }

    java.io.File outputFile = new java.io.File(outputPath + java.io.File.separator + fileName + "." + serializationMode + ".pdf");
View Full Code Here

Examples of java.util.Scanner

  {
    System.out.println("\n" + message);
    System.out.println("Press ENTER to continue");
    try
    {
      Scanner in = new Scanner(System.in);
      in.nextLine();
    }
    catch(Exception e)
    {}
  }
View Full Code Here

Examples of java.util.Scanner

  /**
   * Tests for name.
   */
  @Test
  public void testname() throws Exception {
    Scanner sc = new Scanner("forging;123").useDelimiter(";");
    assertFalse(sc.hasNextInt());
    assertThat(sc.next(), is("forging"));
    assertTrue(sc.hasNextInt());
    assertThat(sc.next(), is("123"));
   
  }
View Full Code Here

Examples of java.util.Scanner

  protected boolean executeBatch(final String commandLine) {
    final File commandFile = new File(commandLine);
    if (commandFile.exists()) {
      try {
        return executeCommands(new Scanner(commandFile).useDelimiter(";"));
      } catch (FileNotFoundException fnfe) {
        return false;
      }
    } else {
      return executeCommands(commandLine);
View Full Code Here

Examples of java.util.Scanner

   *            the input URI sting
   * @return a list of file
   */
  public static List<File> textURIListToFileList(String data) {
    List<File> retVal = new java.util.ArrayList<File>(1);
    Scanner scanner = new Scanner(data);
    scanner.useDelimiter(URI_DELIMITER);
    while (scanner.hasNext()) {
      String token = scanner.next();
      if (token != null && !token.startsWith("#")) {
        try {
          File currentFile = new File(new URI(token));
          if (currentFile.exists()) {
            retVal.add(currentFile);
View Full Code Here

Examples of java_cup.runtime.Scanner

      progressMonitor = new NullProgressMonitor();
    }

    progressMonitor.beginTask(
        "Creating Abstract Syntax Tree for source...", 3); //$NON-NLS-1$
    final Scanner lexer = this.ast.lexer();
    final lr_parser phpParser = this.ast.parser();
    progressMonitor.worked(1);
    phpParser.setScanner(lexer);
    progressMonitor.worked(2);
    final Symbol symbol = phpParser.parse();
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.