List of usage examples for java.util Scanner Scanner
public Scanner(ReadableByteChannel source)
From source file:com.precioustech.fxtrading.oanda.restapi.marketdata.historic.HistoricMarketDataOnDemandDemo.java
public static void main(String[] args) throws Exception { usage(args);/* w ww . j a v a 2s .c o m*/ final String url = args[0]; final String accessToken = args[1]; HistoricMarketDataProvider<String> historicMarketDataProvider = new OandaHistoricMarketDataProvider(url, accessToken); Scanner scanner = new Scanner(System.in); scanner.useDelimiter(System.getProperty("line.separator")); System.out.print("Instrument" + TradingConstants.COLON); String ccyPair = scanner.next(); TradeableInstrument<String> instrument = new TradeableInstrument<>(ccyPair.toUpperCase()); System.out.print( "Granularity" + ArrayUtils.toString(CandleStickGranularity.values()) + TradingConstants.COLON); CandleStickGranularity granularity = CandleStickGranularity.valueOf(scanner.next().toUpperCase()); System.out.print("Time Range Candles(t) or Last N Candles(n)?:"); String choice = scanner.next(); List<CandleStick<String>> candles = null; if ("t".equalsIgnoreCase(choice)) { System.out.print("Start Time(" + datefmtLabel + ")" + TradingConstants.COLON); String startStr = scanner.next(); Date startDt = sdf.parse(startStr); System.out.print(" End Time(" + datefmtLabel + ")" + TradingConstants.COLON); String endStr = scanner.next(); Date endDt = sdf.parse(endStr); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, new DateTime(startDt.getTime()), new DateTime(endDt.getTime())); } else { System.out.print("Last how many candles?" + TradingConstants.COLON); int n = scanner.nextInt(); candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, n); } System.out.println(center("Time", timeColLen) + center("Open", priceColLen) + center("Close", priceColLen) + center("High", priceColLen) + center("Low", priceColLen)); System.out.println(repeat("=", timeColLen + priceColLen * 4)); for (CandleStick<String> candle : candles) { System.out.println(center(sdf.format(candle.getEventDate().toDate()), timeColLen) + formatPrice(candle.getOpenPrice()) + formatPrice(candle.getClosePrice()) + formatPrice(candle.getHighPrice()) + formatPrice(candle.getLowPrice())); } scanner.close(); }
From source file:org.springintegration.demo.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments//from w w w.j a va 2 s . co m */ public static void main(final String... args) { LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n========================================================="); final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/integration/*-context.xml"); context.registerShutdownHook(); final Scanner scanner = new Scanner(System.in); 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 (true) { final String input = scanner.nextLine(); if ("q".equals(input.trim())) { break; } } LOGGER.info("Exiting application...bye."); System.exit(0); }
From source file:com.excelsiorsoft.transformer.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments//from w w w. ja v a 2 s .c o m */ public static void main(final String... args) { LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n========================================================="); final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/integration/*-context.xml"); context.registerShutdownHook(); SpringIntegrationUtils.displayDirectories(context); final Scanner scanner = new Scanner(System.in); LOGGER.info("\n=========================================================" + "\n " + "\n Please press 'q + Enter' to quit the application. " + "\n " + "\n========================================================="); while (!scanner.hasNext("q")) { //Do nothing unless user presses 'q' to quit. } LOGGER.info("Exiting application...bye."); System.exit(0); }
From source file:com.chargebee.Application.Amountediting.java
public static void main(String[] args) throws IOException, Exception { Scanner sc = new Scanner(System.in); System.out.println("Input CSV File: "); String source = sc.nextLine(); System.out.println("Input JSON File: "); String requirements = sc.nextLine(); System.out.println("Output CSV File: "); String output = sc.nextLine(); Amountediting ae = new Amountediting(); JSONObject jobj = MethodBank.readJsonObjectData(requirements); CSVParser parser = MethodBank.parserInitializer(source); CSVPrinter printer = MethodBank.printerInitializer(output); ae.formatter(parser, printer, jobj); parser.close();//from w w w . j ava2 s .com printer.close(); }
From source file:com.lv.tica.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments// w w w .jav a 2 s . c om */ public static void main(final String... args) { LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration!!! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n========================================================="); 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 (true) { final String input = scanner.nextLine(); if ("q".equals(input.trim())) { break; } try { System.out.println("Converted to upper-case: " + service.convertToUpperCase(input)); } catch (Exception e) { LOGGER.error("An exception was caught: " + e); } System.out.print("Please enter a string and press <enter>:"); } LOGGER.info("Exiting application...bye."); System.exit(0); }
From source file:in.datashow.zla.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments//from www . ja v a2 s . c o m */ public static void main(final String... args) { LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n========================================================="); 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 (true) { final String input = scanner.nextLine(); if ("q".equals(input.trim())) { break; } try { System.out.println("Converted to upper-case: " + service.convertToUpperCase(input)); } catch (Exception e) { LOGGER.error("An exception was caught: " + e); } System.out.print("Please enter a string and press <enter>:"); } LOGGER.info("Exiting application...bye."); System.exit(0); }
From source file:com.github.xbn.examples.regexutil.non_xbn.UserInputNumInRangeWRegex.java
public static final void main(String[] ignored) { int num = -1; boolean isNum = false; int iRangeMax = 2055; //"": Dummy string, to reuse matcher Matcher mtchrNumNegThrPos = Pattern.compile("-?\\b(20(5[0-5]|[0-4][0-9])|1?[0-9]{1,3})\\b").matcher(""); do {//from www . j av a 2 s .com System.out.print("Enter a number between -" + iRangeMax + " and " + iRangeMax + ": "); String strInput = (new Scanner(System.in)).next(); if (!NumberUtils.isNumber(strInput)) { System.out.println("Not a number. Try again."); } else if (!mtchrNumNegThrPos.reset(strInput).matches()) { System.out.println("Not in range. Try again."); } else { //Safe to convert num = Integer.parseInt(strInput); isNum = true; } } while (!isNum); System.out.println("Number: " + num); }
From source file:com.super_bits.modulos.paginas.adminTools.PgAdminContainerObjetoTest.java
public static void main(String[] paramentros) { // Ask for user input System.out.print("Enter 1st value:"); // use scanner to read the console input Scanner scan = new Scanner(System.in); String valor = scan.next();//from www .ja v a2s .c om double valorAtualizado = Double.parseDouble(valor) * 8.333; double calculoMultiplo = 10 * (Math.ceil(Math.abs(valorAtualizado / 10))); System.out.println(calculoMultiplo); double teste = (double) Math.round(Double.parseDouble(valor) * 8.3d) * 10 / 10d; System.out.println("TEste:" + teste); System.out.println("Result of the operation is " + valor); System.out.println(Precision.round(0.912385, 0, BigDecimal.ROUND_HALF_UP)); int yourScale = 10; System.out.println(BigDecimal.valueOf(0.42344534534553453453 - 0.42324534524553453453).setScale(yourScale, BigDecimal.ROUND_HALF_UP)); }
From source file:jshm.util.Crypto.java
public static void main(String[] args) { Scanner s = new Scanner(System.in); String in = s.nextLine();/*from ww w.ja va2 s . c o m*/ System.out.println(args.length > 0 && args[0].toLowerCase().startsWith("d") ? decrypt(in) : encrypt(in)); }
From source file:com.vinod.spring.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments//from ww w .j a v a 2 s .c o m */ public static void main(final String... args) { if (LOGGER.isInfoEnabled()) { LOGGER.info("\n=========================================================" + "\n " + "\n Welcome to Spring Integration! " + "\n " + "\n For more information please visit: " + "\n http://www.springsource.org/spring-integration " + "\n " + "\n========================================================="); } final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/integration/*-context.xml"); context.registerShutdownHook(); SpringIntegrationUtils.displayDirectories(context); final Scanner scanner = new Scanner(System.in); if (LOGGER.isInfoEnabled()) { LOGGER.info("\n=========================================================" + "\n " + "\n Please press 'q + Enter' to quit the application. " + "\n " + "\n========================================================="); } while (!scanner.hasNext("q")) { //Do nothing unless user presses 'q' to quit. } if (LOGGER.isInfoEnabled()) { LOGGER.info("Exiting application...bye."); } System.exit(0); }