Package java.util

Examples of java.util.Scanner


  public ResourceMount() {
    ImmutableSortedSet.Builder<String> files = ImmutableSortedSet.naturalOrder();
    InputStream fileList = getClass().getResourceAsStream(RESOURCE_PATH + "files.lst");
    if (fileList != null) {
      Scanner sc = new Scanner(fileList);

      while (sc.hasNextLine()) {
        String fileName = sc.nextLine();
        files.add(fileName);
      }

      sc.close();
    }

    this.files = files.build();
  }
View Full Code Here


        if (rulesIS == null) {
            throw new IllegalArgumentException("Unable to load resource: " + resName);
        }

        return new Scanner(rulesIS, ResourceConstants.ENCODING);
    }
View Full Code Here

        if (rulesIS == null) {
            throw new IllegalArgumentException("Unable to load resource: " + resName);
        }

        return new Scanner(rulesIS, ResourceConstants.ENCODING);
    }
View Full Code Here

        String content = scriptContent.evaluate(build, listener, ScriptContent.MACRO_NAME);

        // read expected file in resource to easy compare
        String expectedFile = "hudson/plugins/emailext/templates/" + "content-token.result";
        InputStream in = getClass().getClassLoader().getResourceAsStream(expectedFile);
        String expected = new Scanner(in).useDelimiter("\\Z").next();
       
        // windows has a \r in each line, so make sure the comparison works correctly
        if(Functions.isWindows()) {
            expected = expected.replace("\r", "");
        }
View Full Code Here

        String content = scriptContent.evaluate(build, listener, ScriptContent.MACRO_NAME);

        // read expected file in resource to easy compare
        String expectedFile = "hudson/plugins/emailext/templates/" + "groovy-sample.result";
        InputStream in = getClass().getClassLoader().getResourceAsStream(expectedFile);
        String expected = new Scanner(in).useDelimiter("\\Z").next();
       
        // windows has a \r in each line, so make sure the comparison works correctly
        if(Functions.isWindows()) {
            expected = expected.replace("\r", "");
        }
View Full Code Here

        }

        LOG.trace("Loading to 1st level cache from idempotent filestore: {}", fileStore);

        cache.clear();
        Scanner scanner = null;
        try {
            scanner = new Scanner(fileStore);
            scanner.useDelimiter(STORE_DELIMITER);
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                cache.put(line, line);
            }
        } catch (IOException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        } finally {
            if (scanner != null) {
                scanner.close();
            }
        }

        LOG.debug("Loaded {} to the 1st level cache from idempotent filestore: {}", cache.size(), fileStore);
    }
View Full Code Here

        final AbstractApplicationContext context =
                new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/*-context.xml");

        context.registerShutdownHook();

        final Scanner scanner = new Scanner(System.in);

        final CoffeeService service = context.getBean(CoffeeService.class);

        LOGGER.info(LINE
                  + NEWLINE
                  + "\n    Please press 'q + Enter' to quit the application.    "
                  + NEWLINE
                  + LINE);

        System.out.print("Please enter 'list' and press <enter> to get a list of coffees.");
        System.out.print("Enter a coffee id, e.g. '1' and press <enter> to get a description.\n\n");

        while (!scanner.hasNext("q")) {

          String input = scanner.nextLine();

          if ("list".equalsIgnoreCase(input)) {
            List<CoffeeBeverage> coffeeBeverages = service.findAllCoffeeBeverages();

            for (CoffeeBeverage coffeeBeverage : coffeeBeverages) {
View Full Code Here

  public List<Influenza_N_P_CR_Element> processFile(String fileName, ProteinCache cacheImpl) {
    List<Influenza_N_P_CR_Element> outList =  new ArrayList<Influenza_N_P_CR_Element>();
    System.out.println("Processing Influenza file " + fileName);
    try {
      Scanner scanner = new Scanner(new File(fileName.trim()));
      scanner.useDelimiter(SecurityActions.getProperty("line.separator"));
      while (scanner.hasNext()) {

        Influenza_N_P_CR_Element x = parseLine(scanner.next());
        outList.add(x);
      }
      scanner.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    System.out.println("Processed " + outList.size() + " records from file");
    return outList;
View Full Code Here

  }

  private static Influenza_N_P_CR_Element parseLine(String line) {
    Influenza_N_P_CR_Element currRec = new Influenza_N_P_CR_Element();

    Scanner lineScanner = new Scanner(line);
    lineScanner.useDelimiter("\t");
    while (lineScanner.hasNext()) {
      try {
        currRec.setGanNucleoid(lineScanner.next());
        try {
          while (true) {
            String protein_GAN = lineScanner.next();
            String protein_CR = lineScanner.next();
            currRec.setProtein_Data(protein_GAN, protein_CR);
          }
        } catch (NoSuchElementException ex) {
          // ignore exception
        }
View Full Code Here

    }

    protected static String slurpAsString(InputStream is) throws IOException
    {
        // See <weblogs.java.net/blog/pat/archive/2004/10/stupid_scanner_1.html>
        Scanner scanner = new Scanner(is, "UTF-8");
        try
        {
            scanner.useDelimiter("\\A");

            return scanner.hasNext() ? scanner.next() : null;
        }
        finally
        {
            try
            {
                scanner.close();
            }
            catch (Exception e)
            {
                // Ignore...
            }
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.