Package java.util

Examples of java.util.Scanner


   
    /**
     * Load the resources from file.
     */
    private void load() {
        Scanner scanner = null;
        try {
           
            scanner = new Scanner(file, "UTF-8");
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();

                String[] values = line.split("=");
                if (values != null && values.length >= 2) {
                    String value = values[1];
                    if (values.length > 2) {
View Full Code Here


                s = s + "&" + k.getKey() + "=" + k.getValue();               
              }
            // final String s = searchaddress+"&query="+post.get("search")+"&maximumRecords="+post.get("maximumRecords")+"&startRecord="+post.get("startRecord");                      
            final URL url = new URL(s);            
            is = url.openStream();
            final String httpout = new Scanner(is).useDelimiter( "\\Z" ).next();           
            prop.put("http", httpout);
          }
          catch ( final Exception e ) {
            prop.put("url", "error!");
          }
View Full Code Here

  }
 
  private void doParse(){
    folderNames = new ArrayList<String>();   
    if(parseString != null){
      Scanner scanner = new Scanner(parseString.trim()).useDelimiter(",");
      while(scanner.hasNext()){
        String fn = scanner.next().trim();
        folderNames.add(fn);
      }
    }
  }
View Full Code Here

      throw new QuoteNotBalancedException();
    }
  }
  */
  private void doParse(String regex){
    Scanner scanner = new Scanner(parseString.trim());   
    if(regex != null){
      scanner = scanner.useDelimiter(regex);
    }
    while(scanner.hasNext()){
      String tagTerm = getNextTagTerm(scanner);
      logger.debug("tagTerm="+tagTerm);
      if(tagTerm.contains(":") == true){     
        MachineTag machineTagTerm = getMachineTag(tagTerm);
        if(machineTagTerm != null){         
View Full Code Here

      catch(Exception e)
      {
         System.out.println("Error while trying to load data:"+e.getMessage());
         System.out.println("Maybe it does not exist and need to be created.");
      }
      Scanner in = new Scanner(System.in);
     
      while(true)
      {
         String commandStr = "0: Encrypt Keystore Password " +
             "1:Specify KeyStore " +
             "2:Create Password  " +
             "3: Remove a domain " +
             "4:Enquire Domain " +
             "5:Exit";
        
         System.out.println(commandStr);
         int choice = in.nextInt();
        
         switch(choice)
         {
            case 0: //Encrypt Keystore Password
               System.out.println("Enter Keystore password");
               String passStr = in.next();
               String saltStr ="";
               do
               {
                  System.out.println("Enter Salt (String should be at least 8 characters)");
                  saltStr = in.next();
               }while(saltStr.length() < 8);
              
               System.out.println("Enter Iterator Count (integer value)");
               int iterationCount = in.nextInt();
              
               String ksPassFileName = PasswordMaskManagement.keystorePassEncFileName;
               String[] filePasswordArgs = new String[]
                                          {saltStr, iterationCount+""
                     , passStr, ksPassFileName};
               try
               {
                  //Check if password directory exists
                  File passwordDir = new File("password");
                  if(passwordDir.exists() == false)
                     passwordDir.mkdir();
                 
                  FilePassword.main(filePasswordArgs);
               }
               catch (Exception e1)
               {
                  throw new RuntimeException(e1);
               }
               System.out.println("Keystore Password encrypted into " + ksPassFileName);
               break;
              
            case 1: //Specify keystore
               System.out.println("Enter Keystore location including the file name");
               String loc = in.next();
               System.out.println("Enter Keystore alias");
               String alias = in.next();
              
               try
               {
                  pwm.setKeyStoreDetails(loc, alias);
               }
               catch(Exception e)
               {
                  System.out.println("Exception being raised. Try to first encrypt the keystore password.");
                  System.out.println("or check the keystore location.");
               }
               load();
               break;
            case 2//Create a password
               if(pwm.keyStoreExists())
               {
                  System.out.println("Enter security domain:");
                  String domain = in.next();
                  System.out.println("Enter passwd:");
                  String p = in.next();
                  pwm.storePassword(domain, p.toCharArray());
                  System.out.println("Password created for domain:" + domain);
               }
               else
                  System.out.println("Enter Keystore details first");
               break;
            case 3: //Remove a domain
               if(pwm.keyStoreExists())
               {
                  System.out.println("Enter security domain to be removed:");
                  String domainToRemove = in.next();
                  pwm.removePassword(domainToRemove);
               }
               else
                  System.out.println("Enter Keystore details first");
               break;
            case 4: //Check if domain exists
               if(pwm.keyStoreExists())
               {
                  System.out.println("Enter security domain to enquire:");
                  String domainToEnquire = in.next();
                  System.out.println("Exists = " + pwm.exists(domainToEnquire));
               }
               else
                  System.out.println("Enter Keystore details first");
               break;
View Full Code Here

  {
    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

  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

          (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

    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

  {
    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

TOP

Related Classes of java.util.Scanner

Copyright © 2018 www.massapicom. 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.