Package java.util

Examples of java.util.Scanner


                System.out.format("+-------+------+---------------------------------+----------+---------+------------------+%n");
            }
        }

        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


   *
   * @param args - command line arguments
   */
  public static void main(final String... args) {

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

    System.out.println("\n========================================================="
            + "\n                                                         "
            + "\n    Welcome to the Spring Integration JPA Sample!        "
            + "\n                                                         "
            + "\n    For more information please visit:                   "
            + "\n    http://www.springintegration.org/                    "
            + "\n                                                         "
            + "\n=========================================================" );

    System.out.println("Please enter a choice and press <enter>: ");
    System.out.println("\t1. Use Hibernate");
    System.out.println("\t2. Use OpenJPA");
    System.out.println("\t3. Use EclipseLink");

    System.out.println("\tq. Quit the application");
    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())) {
        context.getEnvironment().setActiveProfiles("openjpa");
        break;
      } else if("3".equals(input.trim())) {
        context.getEnvironment().setActiveProfiles("eclipselink");
        break;
      } else if("q".equals(input.trim())) {
        System.out.println("Exiting application...bye.");
        System.exit(0);
      } else {
        System.out.println("Invalid choice\n\n");
        System.out.print("Enter you choice: ");
      }
    }

    context.load("classpath:META-INF/spring/integration/*-context.xml");
    context.registerShutdownHook();
    context.refresh();

    final PersonService personService = context.getBean(PersonService.class);

    System.out.println("Please enter a choice and press <enter>: ");
    System.out.println("\t1. List all people");
    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

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

    context.registerShutdownHook();

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

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

    LOGGER.info(LINE_SEPARATOR
          + EMPTY_LINE
          + "\n    Please press 'q + Enter' to quit the application.                     "
          + EMPTY_LINE
          + LINE_SEPARATOR
          + EMPTY_LINE
          + "\n    This example illustrates the usage of the Content Enricher.           "
          + EMPTY_LINE
          + "\n    Usage: Please enter 1 or 2 or 3 + Enter                               "
          + EMPTY_LINE
          + "\n    3 different message flows are triggered. For sample 1+2 a             "
          + "\n    user object containing only the username is passed in.                "
          + "\n    For sample 3 a Map with the 'username' key is passed in and enriched  "
          + "\n    with the user object using the 'user' key.                            "
          + EMPTY_LINE
          + "\n    1: In the Enricher, pass the full User object to the request channel. "
          + "\n    2: In the Enricher, pass only the username to the request channel.    "
          + "\n    3: In the Enricher, pass only the username to the request channel.    "
          + 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

   *
   * @param args - command line arguments
   */
  public static void main(final String... args) {

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

    System.out.println("\n========================================================="
            + "\n                                                         "
            + "\n    Welcome to the Spring Integration                    "
            + "\n          TCP-Client-Server Sample!                      "
            + "\n                                                         "
            + "\n    For more information please visit:                   "
            + "\n    http://www.springintegration.org/                    "
            + "\n                                                         "
            + "\n=========================================================" );

    final GenericXmlApplicationContext context = Main.setupContext();
    final SimpleGateway gateway = context.getBean(SimpleGateway.class);
    final AbstractServerConnectionFactory crLfServer = context.getBean(AbstractServerConnectionFactory.class);

    System.out.print("Waiting for server to accept connections...");
    TestingUtilities.waitListening(crLfServer, 10000L);
    System.out.println("running.\n\n");

    System.out.println("Please enter some text and press <enter>: ");
    System.out.println("\tNote:");
    System.out.println("\t- Entering FAIL will create an exception");
    System.out.println("\t- Entering q will quit the application");
    System.out.print("\n");
    System.out.println("\t--> Please also check out the other samples, " +
            "that are provided as JUnit tests.");
    System.out.println("\t--> You can also connect to the server on port '" + crLfServer.getPort() + "' using Telnet.\n\n");

    while (true) {

      final String input = scanner.nextLine();

      if("q".equals(input.trim())) {
        break;
      }
      else {
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

@EnableAutoConfiguration(exclude = TwitterAutoConfiguration.class)
public class Application {

  public static void main(String[] args) throws Exception {
    ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
    Scanner scanner = new Scanner(System.in);
    String hashTag = scanner.nextLine();
    System.out.println(ctx.getBean(Gateway.class).sendReceive(hashTag));
    scanner.close();
    ctx.close();
  }
View Full Code Here

    final SearchRequestor searchRequestor = context.getBean(SearchRequestor.class);
    final SearchA searchA = context.getBean(SearchA.class);
    final SearchB searchB = context.getBean(SearchB.class);

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

    System.out.println("Please enter a choice and press <enter>: ");
    System.out.println("\t1. Submit 2 search queries, 2 results returned.");
    System.out.println("\t2. Submit 2 search queries, 1 search query takes too long, 1 result returned.");
    System.out.println("\t3. Submit 2 search queries, 2 search queries take too long, 0 results returned.");

    System.out.println("\tq. Quit the application");
    System.out.print("Enter your choice: ");

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

      if("1".equals(input.trim())) {
        searchA.setExecutionTime(1000L);
        searchB.setExecutionTime(1000L);
        final CompositeResult result = searchRequestor.search(TestUtils.getCompositeCriteria());
View Full Code Here

    context.load("classpath:META-INF/spring/*.xml");
    context.refresh();

    final TravelGateway travelGateway = context.getBean("travelGateway", TravelGateway.class);

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

    System.out.println("\n========================================================="
            + "\n                                                         "
            + "\n    Welcome to the Spring Integration Travel App!        "
            + "\n                                                         "
            + "\n    For more information please visit:                   "
            + "\n    http://www.springintegration.org/                    "
            + "\n                                                         "
            + "\n=========================================================" );

    System.out.println("Please select the city, for which you would like to get traffic and weather information:");

    for (City city : City.values()) {
      System.out.println(String.format("\t%s. %s", city.getId(), city.getName()));
    }
    System.out.println("\tq. Quit the application");
    System.out.print("Enter your choice: ");

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

      if("q".equals(input.trim())) {
        System.out.println("Exiting application...bye.");
        System.exit(0);
      } else {
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 DynamicPeriodicTrigger trigger = context.getBean(DynamicPeriodicTrigger.class);

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

        System.out.print("Please enter a non-negative numeric value and press <enter>: ");

        while (true) {
         
          final String input = scanner.nextLine();
         
          if("q".equals(input.trim())) {
            break;
          }
         
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 StringConversionService service = context.getBean(StringConversionService.class);

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

    System.out.print("Please enter a string and press <enter>: ");

    while (!scanner.hasNext("q")) {
      String input = scanner.nextLine();

      System.out.println("Converting String to Uppcase using Stored Procedure...");
      String inputUpperCase = service.convertToUpperCase(input);

      System.out.println("Retrieving Numeric value via Sql Function...");
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.