Package java.util

Examples of java.util.Scanner.nextLine()


      Scanner scanner = new Scanner(resource.getInputStream());
      StringBuilder builder = new StringBuilder();

      while (scanner.hasNextLine()) {
        builder.append(scanner.nextLine()).append("\n");
      }

      scanner.close();

      return builder.toString();
View Full Code Here


    configureExport(new ExportConf.Builder("xml").header(true).build());
    processExport(new XmlExport());
   
    // The header must exist
    Scanner scanner = new Scanner(new String(baos.toByteArray()));
    String firstLine = scanner.nextLine();
   
    assertThat(firstLine).contains("<?xml version=\"1.0\"?>");
    assertThat(firstLine).contains("<persons>");
    assertThat(firstLine).contains("</persons>");
    assertThat(firstLine).contains("<person id=\"1\" firstName=\"Selma\" lastName=\"Maldonado\" city=\"\" mail=\"venenatis@Duisvolutpat.com\"></person><person id=\"2\" firstName=\"Vanna\" lastName=\"Salas\" city=\"Denny\" mail=\"bibendum.fermentum.metus@ante.ca\"></person>");
View Full Code Here

            if (f.isDirectory()) {
                total += countWildcardPhraseFrequencies(f, pattern);
            } else if (f.getName().endsWith(".txt")) {
                Scanner sc = new Scanner(f);
                while (sc.hasNext()) {
                    String line = sc.nextLine();
                    if (line.matches(pattern)) {
                        total++;
                    }
                }
            }
View Full Code Here

    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();
    }
View Full Code Here

        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 {
View Full Code Here

        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

            }
        }

        System.out.print("Do you want to proceed? [Y/N]: ");
        Scanner in = new Scanner(System.in);
        String choice = in.nextLine();

        if(choice.equals("Y") || choice.equals("y")) {
            return true;
        } else if(choice.equals("N") || choice.equals("n")) {
            return false;
View Full Code Here

    System.out.print("Enter you choice: ");

    final GenericXmlApplicationContext context = new GenericXmlApplicationContext();

    while (true) {
      final String input = scanner.nextLine();

      if("1".equals(input.trim())) {
        context.getEnvironment().setActiveProfiles("hibernate");
        break;
      } else if("2".equals(input.trim())) {
View Full Code Here

    System.out.println("\t2. Create a new person");
    System.out.println("\tq. Quit the application");
    System.out.print("Enter you choice: ");

    while (true) {
      final String input = scanner.nextLine();

      if("1".equals(input.trim())) {
        findPeople(personService);
      } else if("2".equals(input.trim())) {
        createPersonDetails(scanner,personService);
View Full Code Here

          + EMPTY_LINE
          + LINE_SEPARATOR);

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

      final String input = scanner.nextLine();

      User user = new User("foo", null, null);

      if ("1".equals(input)) {
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.