List of usage examples for java.lang System in
InputStream in
To view the source code for java.lang System in.
Click Source Link
From source file:com.jff.searchapicluster.server.mina.Server.java
public static void main(String[] args) throws Throwable { org.apache.commons.configuration.Configuration config = new PropertiesConfiguration("settings.txt"); int serverPort = config.getInt("listenPort"); NioSocketAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("com/jff/searchapicluster/core/mina/codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory())); acceptor.getFilterChain().addLast("logger", new LoggingFilter()); acceptor.setHandler(new ServerSessionHandler()); acceptor.bind(new InetSocketAddress(serverPort)); System.out.println("Listening on port " + serverPort); System.out.println("Please enter filename"); // open up standard input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (true) { String filepath = br.readLine(); filepath = "/Users/admin/repos/study_repos/kurs_sp/search_api_cluster/SearchApiClusterServer/task.json"; File file = new File(filepath); Logger.d(LOG_TAG, file.getAbsolutePath()); if (file.exists() && file.isFile()) { Gson gson = new Gson(); SearchTask taskMessage = gson.fromJson(new FileReader(file), SearchTask.class); ServerManager serverManager = ServerManager.getInstance(); Logger.d(LOG_TAG, taskMessage.toString()); serverManager.startProcessTask(taskMessage); } else {//from w w w . j a va2 s .com Logger.d(LOG_TAG, filepath + "not found"); } } }
From source file:org.hyperic.hq.hqapi1.tools.PasswordEncryptor.java
public static void main(String[] args) throws Exception { String password1 = String.valueOf(PasswordField.getPassword(System.in, "Enter password: ")); String password2 = String.valueOf(PasswordField.getPassword(System.in, "Re-Enter password: ")); String encryptionKey = "defaultkey"; if (password1.equals(password2)) { System.out.print("Encryption Key: "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); encryptionKey = in.readLine();//from w w w .j a v a 2s .com if (encryptionKey.length() < 8) { System.out.println("Encryption key too short. Please use at least 8 characters"); System.exit(-1); } } else { System.out.println("Passwords don't match"); System.exit(-1); } System.out.println("The encrypted password is " + encryptPassword(password1, encryptionKey)); }
From source file:com.japp.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments/*from w ww . j a v a2 s . com*/ */ public static void main(final String... args) { if (LOGGER.isInfoEnabled()) { LOGGER.info("\n=========================================================" + "\n " + "\n SFTP-File Transfer POC " + "\n " + "\n========================================================="); } final AbstractApplicationContext context = new ClassPathXmlApplicationContext( "classpath:/launch-context.xml"); context.registerShutdownHook(); SpringIntegrationUtils.displayDirectories(context); final Scanner scanner = new Scanner(System.in); JobLauncher jobLauncher = context.getBean("jobLauncher", JobLauncher.class); Job job = context.getBean("job1", Job.class); try { jobLauncher.run(job, new JobParameters()); } catch (JobExecutionAlreadyRunningException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (JobRestartException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (JobInstanceAlreadyCompleteException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (JobParametersInvalidException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } 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); }
From source file:lab.mage.rate.example.NewsServer.java
public static void main(String[] args) throws Exception { // configure resource final ResourceConfig resourceConfig = new ResourceConfig(); // set news service final NewsService newsService = new NewsService(); resourceConfig.register(newsService); // set Jackson as JSON provider final ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.setDateFormat(new SimpleDateFormat(ISO_8601_DATE_PATTERN)); final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(mapper);/*from ww w .ja va 2 s . c o m*/ resourceConfig.register(provider); // create Grizzly instance and add handler final HttpHandler handler = ContainerFactory.createContainer(GrizzlyHttpContainer.class, resourceConfig); final URI uri = new URI("http://localhost:4711/"); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(uri); final ServerConfiguration config = server.getServerConfiguration(); config.addHttpHandler(handler, "/api"); // start server.start(); System.in.read(); }
From source file:com.liferay.nativity.test.TestDriver.java
public static void main(String[] args) { _intitializeLogging();/* w ww .j a va 2 s . co m*/ List<String> items = new ArrayList<String>(); items.add("ONE"); NativityMessage message = new NativityMessage("BLAH", items); try { _logger.debug(_objectMapper.writeValueAsString(message)); } catch (JsonProcessingException jpe) { _logger.error(jpe.getMessage(), jpe); } _logger.debug("main"); NativityControl nativityControl = NativityControlUtil.getNativityControl(); FileIconControl fileIconControl = FileIconControlUtil.getFileIconControl(nativityControl, new TestFileIconControlCallback()); ContextMenuControlUtil.getContextMenuControl(nativityControl, new TestContextMenuControlCallback()); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); nativityControl.connect(); String read = ""; boolean stop = false; try { while (!stop) { _list = !_list; _logger.debug("Loop start..."); _logger.debug("_enableFileIcons"); _enableFileIcons(fileIconControl); _logger.debug("_registerFileIcon"); _registerFileIcon(fileIconControl); _logger.debug("_setFilterPath"); _setFilterPath(nativityControl); _logger.debug("_setSystemFolder"); _setSystemFolder(nativityControl); _logger.debug("_updateFileIcon"); _updateFileIcon(fileIconControl); _logger.debug("_clearFileIcon"); _clearFileIcon(fileIconControl); _logger.debug("Ready?"); if (bufferedReader.ready()) { _logger.debug("Reading..."); read = bufferedReader.readLine(); _logger.debug("Read {}", read); if (read.length() > 0) { stop = true; } _logger.debug("Stopping {}", stop); } } } catch (IOException e) { _logger.error(e.getMessage(), e); } _logger.debug("Done"); }
From source file:io.milton.grizzly.GrizzlyServer.java
public static void main(String[] args) throws IOException, InterruptedException { int port = 8080; if (args.length > 0) { port = Integer.parseInt(args[0]); }/*from ww w . j ava2 s . c om*/ Integer sslPort = null; if (args.length > 1) { sslPort = Integer.parseInt(args[1]); } GrizzlyServer k = new GrizzlyServer(); k.start(); System.out.println("Press any key to stop the server..."); System.in.read(); }
From source file:com.wordnik.swaggersocket.samples.NettoSphere.java
public static void main(String[] args) throws IOException { ReflectorServletProcessor rsp = new ReflectorServletProcessor(); rsp.setServletClassName(CXFNonSpringJaxrsServlet.class.getName()); int p = getHttpPort(); Config.Builder b = new Config.Builder(); b.resource("./app").initParam(ApplicationConfig.WEBSOCKET_CONTENT_TYPE, "application/json") .initParam(ApplicationConfig.WEBSOCKET_METHOD, "POST") .initParam("jaxrs.serviceClasses", SwaggerSocketResource.class.getName() + "," + FileServiceResource.class.getName()) .initParam("jaxrs.providers", JacksonJsonProvider.class.getName()) .initParam("com.wordnik.swaggersocket.protocol.lazywrite", "true") .initParam("com.wordnik.swaggersocket.protocol.emptyentity", "true") .interceptor(new SwaggerSocketProtocolInterceptor()).resource("/*", rsp).port(p).host("127.0.0.1") .build();/*from w ww .j a v a 2 s . c o m*/ Nettosphere s = new Nettosphere.Builder().config(b.build()).build(); s.start(); String a = ""; logger.info("NettoSphere SwaggerSocket Server started on port {}", p); logger.info("Type quit to stop the server"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while (!(a.equals("quit"))) { a = br.readLine(); } System.exit(-1); }
From source file:edu.cmu.lti.oaqa.bio.index.medline.annotated.query.SimpleQueryApp.java
public static void main(String[] args) { Options options = new Options(); options.addOption("u", null, true, "Solr URI"); options.addOption("n", null, true, "Max # of results"); CommandLineParser parser = new org.apache.commons.cli.GnuParser(); try {// ww w .j ava 2s. c o m CommandLine cmd = parser.parse(options, args); String solrURI = null; solrURI = cmd.getOptionValue("u"); if (solrURI == null) { Usage("Specify Solr URI"); } SolrServerWrapper solr = new SolrServerWrapper(solrURI); int numRet = 10; if (cmd.hasOption("n")) { numRet = Integer.parseInt(cmd.getOptionValue("n")); } List<String> fieldList = new ArrayList<String>(); fieldList.add(UtilConstMedline.ID_FIELD); fieldList.add(UtilConstMedline.SCORE_FIELD); fieldList.add(UtilConstMedline.ARTICLE_TITLE_FIELD); fieldList.add(UtilConstMedline.ENTITIES_DESC_FIELD); fieldList.add(UtilConstMedline.ABSTRACT_TEXT_FIELD); BufferedReader sysInReader = new BufferedReader(new InputStreamReader(System.in)); Joiner commaJoiner = Joiner.on(','); while (true) { System.out.println("Input query: "); String query = sysInReader.readLine(); if (null == query) break; QueryTransformer qt = new QueryTransformer(query); String tranQuery = qt.getQuery(); System.out.println("Translated query:"); System.out.println(tranQuery); System.out.println("========================="); SolrDocumentList res = solr.runQuery(tranQuery, fieldList, numRet); System.out.println("Found " + res.getNumFound() + " entries"); for (SolrDocument doc : res) { String id = (String) doc.getFieldValue(UtilConstMedline.ID_FIELD); float score = (Float) doc.getFieldValue(UtilConstMedline.SCORE_FIELD); String title = (String) doc.getFieldValue(UtilConstMedline.ARTICLE_TITLE_FIELD); String titleAbstract = (String) doc.getFieldValue(UtilConstMedline.ABSTRACT_TEXT_FIELD); System.out.println(score + " PMID=" + id + " " + titleAbstract); String entityDesc = (String) doc.getFieldValue(UtilConstMedline.ENTITIES_DESC_FIELD); System.out.println("Entities:"); for (EntityEntry e : EntityEntry.parseEntityDesc(entityDesc)) { System.out.println(String.format("[%d %d] concept=%s concept_ids=%s", e.mStart, e.mEnd, e.mConcept, commaJoiner.join(e.mConceptIds))); } } } solr.close(); } catch (ParseException e) { Usage("Cannot parse arguments"); } catch (Exception e) { System.err.println("Terminating due to an exception: " + e); System.exit(1); } }
From source file:org.springone2gx_2011.integration.resequencer.ResequencerDemo.java
/** * @param args/*from w ww . j ava 2 s. co m*/ */ public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("resequencer-config.xml", ResequencerDemo.class); MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class); inputChannel.send(MessageBuilder.withPayload(5).setCorrelationId(1).setSequenceNumber(5).build()); inputChannel.send(MessageBuilder.withPayload(2).setCorrelationId(1).setSequenceNumber(2).build()); inputChannel.send(MessageBuilder.withPayload(1).setCorrelationId(1).setSequenceNumber(1).build()); inputChannel.send(MessageBuilder.withPayload(2).setCorrelationId(2).setSequenceNumber(2).build()); inputChannel.send(MessageBuilder.withPayload(1).setCorrelationId(2).setSequenceNumber(1).build()); inputChannel.send(MessageBuilder.withPayload(4).setCorrelationId(1).setSequenceNumber(4).build()); inputChannel.send(MessageBuilder.withPayload(3).setCorrelationId(1).setSequenceNumber(3).build()); inputChannel.send(MessageBuilder.withPayload(5).setCorrelationId(2).setSequenceNumber(5).build()); inputChannel.send(MessageBuilder.withPayload(4).setCorrelationId(2).setSequenceNumber(4).build()); inputChannel.send(MessageBuilder.withPayload(3).setCorrelationId(2).setSequenceNumber(3).build()); System.in.read(); }
From source file:org.musa.tcpclients.Main.java
/** * Load the Spring Integration Application Context * * @param args - command line arguments//from w ww . j a va 2 s . c om */ public static void main(final String... args) { final Scanner scanner = new Scanner(System.in); //context.getB GenericXmlApplicationContext context = Main.setupContext(); WarpGateway gateway = (WarpGateway) context.getBean("gw"); System.out.println("running.\n\n"); System.out.println("Please enter numbers to spawn spacemarines :"); System.out.println("1: Gabriel Loken"); System.out.println("2: Nathaniel Garro"); System.out.println("3: Ezekyl Abaddon"); System.out.println("4: Sanguinius"); System.out.println("5: Lucius"); System.out.println("\t- Entering q will quit the application"); System.out.print("\n"); while (true) { final String input = scanner.nextLine(); if ("q".equals(input.trim())) { break; } else { SpaceMarine gabriel = new SpaceMarine("Gabriel Loken", "Luna Wolves", 500, SMRank.CaptainBrother, SMLoyalty.Loyalist, 100); SpaceMarine garro = new SpaceMarine("Nathaniel Garro", "Deathguard", 500, SMRank.CaptainBrother, SMLoyalty.Loyalist, 100); SpaceMarine ezekyl = new SpaceMarine("Ezekyl Abaddon", "Black Legion", 500, SMRank.CaptainBrother, SMLoyalty.Traitor, 100); SpaceMarine sanguinius = new SpaceMarine("Sanguinius", "Blood angels", 999, SMRank.Primarch, SMLoyalty.Loyalist, 600); SpaceMarine lucius = new SpaceMarine("Lucius", "Emperor's children", 500, SMRank.SwordMaster, SMLoyalty.Traitor, 700); SpaceMarine[] spaceMarines = { gabriel, garro, ezekyl, sanguinius, lucius }; int max_id = spaceMarines.length; int num = 0; //input try { num = Integer.parseInt(input); } catch (NumberFormatException e) { System.out.println("unable to parse value"); } if (num >= max_id) { System.out.println("no such spacemarine, using Loken"); num = 0; } System.out.println("teleporting " + spaceMarines[num].getName() + "...."); Message<SpaceMarine> m = MessageBuilder.withPayload(spaceMarines[num]).build(); //context. String reply = (String) gateway.send(m); System.out.println(reply); } } System.out.println("Exiting application...bye."); System.exit(0); }