List of usage examples for java.lang Integer parseInt
public static int parseInt(String s) throws NumberFormatException
From source file:edu.harvard.hms.dbmi.i2b2.api.samples.TraversePaths.java
/** * Runs the traverse paths example./*ww w. ja v a 2 s.c o m*/ * * Requires 6 parameters: * domain userName password ontologyCellURL project depth * * @param args * arguments */ public static void main(String[] args) { if (args.length != 6) { System.out.println("Invalid number of arguments."); System.out.println("java TraversePaths domain userName password ontologyCellURL project depth"); } String domain = args[0]; String userName = args[1]; String password = args[2]; String ontologyCellURL = args[3]; String project = args[4]; int depth = Integer.parseInt(args[5]); TraversePaths traversePaths = new TraversePaths(); try { traversePaths.setup(userName, domain, password, ontologyCellURL, project); HttpClient httpClient = HttpClients.createDefault(); traversePaths.printPath(httpClient, null, 0, depth); } catch (JAXBException | IOException | I2B2InterfaceException e) { System.out.println("An error occurred traverse the paths"); e.printStackTrace(); } System.out.println("\nFinished with " + traversePaths.getTotalCount() + " returned in total"); }
From source file:fr.tpt.atlanalyser.tests.TestClass2RelationalPost2Pre.java
@SuppressWarnings("static-access") public static void main(String[] args) throws IOException { // URL resource = Thread.currentThread().getContextClassLoader() // .getResource("OldAGTExp"); // System.out.println(resource.toString()); // File f = new File(resource.getPath()); // System.out.println(f.toString()); // System.out.println(f.isDirectory()); // System.exit(0); Options options = new Options(); options.addOption(//from w w w . j a v a 2s. c om OptionBuilder.hasArg().withArgName("N").withDescription("Number of parallel jobs").create("j")); options.addOption(OptionBuilder.withDescription("Display help").create("h")); CommandLineParser parser = new BasicParser(); int jobs = 2; try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("h")) { new HelpFormatter().printHelp(TestClass2RelationalPost2Pre.class.getSimpleName(), options); System.exit(0); } if (cmd.hasOption("j")) { jobs = Integer.parseInt(cmd.getOptionValue("j")); } } catch (Exception e) { System.out.println("Incorrect command line arguments"); new HelpFormatter().printHelp(TestClass2RelationalPost2Pre.class.getSimpleName(), options); System.exit(1); } new TestClass2RelationalPost2Pre(models().get(0)[0], jobs).testPost2Pre(); }
From source file:com.sankalp.characterreader.CharacterReader.java
public static void main(String[] args) throws IOException { double learningRate = 0.55; List<NeuralNetwork.Layer> hiddenLayerList = new ArrayList(); hiddenLayerList.add(new NeuralNetwork.Layer(50)); NeuralNetwork neuralNetwork = new NeuralNetwork(new NeuralNetwork.Layer(28 * 28), new NeuralNetwork.Layer(10), hiddenLayerList, learningRate); int trainingSampleCount = 60000; TrainingData trainingData = new TrainingData(new File("/home/sankalpkulshrestha/mnist/train-images/"), trainingSampleCount, new File("/home/sankalpkulshrestha/mnist/train-labels.csv")); int totalEpochs = 30; for (int index = 0; index < totalEpochs; index++) { System.out.println("---------- EPOCH " + index + " ----------"); neuralNetwork.train(trainingData); TrainingData testData = new TrainingData(new File("/home/sankalpkulshrestha/mnist/test-images/"), 10000, new File("/home/sankalpkulshrestha/mnist/test-labels.csv")); System.out.println("Training over"); double accuracy = neuralNetwork.measureAccuracy(testData); System.out.println(accuracy); if (index < totalEpochs - 1) { trainingData.shuffle();//from w w w . ja v a 2 s .c o m trainingData.reset(); } } System.out.println("Model trained. Enter image file names:"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int number = -1; List<String> expectedOutputList = FileUtils .readLines(new File("/home/sankalpkulshrestha/mnist/test-labels.csv"), "UTF-8"); while ((number = Integer.parseInt(br.readLine())) != -1) { int output = neuralNetwork.test(new TrainingData.Sample( new File("/home/sankalpkulshrestha/mnist/test-images/" + number + ".jpg"), 0)); System.out.println(output); } }
From source file:io.hops.metadata.util.DistributedRTRMEvaluation.java
public static void main(String[] args) throws IOException, YarnException, InterruptedException { System.out.println("version 1.0"); if (args.length == 0) { //TODO display help return;/* w w w .j a v a 2 s. com*/ } if (args[0].equals("run")) { int pendingPeriod = Integer.parseInt(args[1]); DistributedRTRMEvaluation drt = new DistributedRTRMEvaluation(pendingPeriod); drt.start(); } else if (args[0].equals("format")) { DistributedRTRMEvaluation drt = new DistributedRTRMEvaluation(); drt.format(); } }
From source file:com.cloudera.oryx.kafka.util.ProduceData.java
public static void main(String[] args) throws Exception { int howMany = Integer.parseInt(args[0]); int intervalMsec = Integer.parseInt(args[1]); String topic = args[2];//from w w w .jav a 2 s. c o m int zkPort = Integer.parseInt(args[3]); int kafkaPort = Integer.parseInt(args[4]); ProduceData producer = new ProduceData(new DefaultCSVDatumGenerator(), zkPort, kafkaPort, topic, howMany, intervalMsec); producer.start(); }
From source file:com.yahoo.gondola.cli.GondolaAgent.java
public static void main(String[] args) throws ParseException, IOException { PropertyConfigurator.configure("conf/log4j.properties"); CommandLineParser parser = new DefaultParser(); Options options = new Options(); options.addOption("port", true, "Listening port"); options.addOption("config", true, "config file"); options.addOption("h", false, "help"); CommandLine commandLine = parser.parse(options, args); if (commandLine.hasOption("help")) { new HelpFormatter().printHelp("GondolaAgent", options); return;//from ww w . j a v a 2s. co m } if (commandLine.hasOption("port")) { port = Integer.parseInt(commandLine.getOptionValue("port")); } else { port = 1200; } if (commandLine.hasOption("config")) { configFile = commandLine.getOptionValue("config"); } config = new Config(new File(configFile)); logger.info("Initialize system, kill all gondola processes"); new DefaultExecutor().execute(org.apache.commons.exec.CommandLine.parse("bin/gondola-local-test.sh stop")); new GondolaAgent(port); }
From source file:Chopstick.java
public static void main(String[] args) { if (args.length < 3) { System.err.println(// w ww.j a va 2 s . c o m "usage:\n" + "java DiningPhilosophers numberOfPhilosophers " + "ponderFactor deadlock timeout\n" + "A nonzero ponderFactor will generate a random " + "sleep time during think().\n" + "If deadlock is not the string " + "'deadlock', the program will not deadlock.\n" + "A nonzero timeout will stop the program after " + "that number of seconds."); System.exit(1); } Philosopher[] philosopher = new Philosopher[Integer.parseInt(args[0])]; Philosopher.ponder = Integer.parseInt(args[1]); Chopstick left = new Chopstick(), right = new Chopstick(), first = left; int i = 0; while (i < philosopher.length - 1) { philosopher[i++] = new Philosopher(left, right); left = right; right = new Chopstick(); } if (args[2].equals("deadlock")) philosopher[i] = new Philosopher(left, first); else // Swapping values prevents deadlock: philosopher[i] = new Philosopher(first, left); // Optionally break out of program: if (args.length >= 4) { int delay = Integer.parseInt(args[3]); if (delay != 0) new Timeout(delay * 1000, "Timed out"); } }
From source file:com.app.server.ShutDownServer.java
/** * @param args// w ww. j a va 2 s .co m * @throws SAXException * @throws IOException */ public static void main(String[] args) throws IOException, SAXException { DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml"))); } catch (FileNotFoundException e) { log.error("Could not load rules xml serverconfig-rules.xml", e); // TODO Auto-generated catch block //e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); ServerConfig serverconfig = (ServerConfig) serverdigester .parse(new InputSource(new FileInputStream("./config/serverconfig.xml"))); try { Socket socket = new Socket("localhost", Integer.parseInt(serverconfig.getShutdownport())); OutputStream outputStream = socket.getOutputStream(); outputStream.write("shutdown WebServer\r\n\r\n".getBytes()); outputStream.close(); } catch (Exception ex) { log.error("Could not able to create socket and write shutdown bytes", ex); //e1.printStackTrace(); } }
From source file:io.milton.grizzly.GrizzlyLoadBalancer.java
public static void main(String[] args) throws IOException, InterruptedException { int port = 8080; if (args.length > 0) { port = Integer.parseInt(args[0]); }/*from w w w .ja v a2s . c o m*/ Integer sslPort = null; if (args.length > 1) { sslPort = Integer.parseInt(args[1]); } GrizzlyLoadBalancer k = new GrizzlyLoadBalancer(); k.start(); System.out.println("Press any key to stop the server..."); System.in.read(); }
From source file:edu.harvard.hms.dbmi.i2b2.api.samples.FactoryTraversePaths.java
/** * Runs the traverse paths example./*from ww w . j a v a2s . com*/ * * Requires 6 parameters: * domain userName password ontologyCellURL project depth * * @param args * arguments */ public static void main(String[] args) { if (args.length != 6) { System.out.println("Invalid number of arguments."); System.out.println("java TraversePaths domain userName password cellURL project depth"); } String domain = args[0]; String userName = args[1]; String password = args[2]; String ontologyCellURL = args[3]; String project = args[4]; int depth = Integer.parseInt(args[5]); FactoryTraversePaths traversePaths = new FactoryTraversePaths(); try { traversePaths.setup(userName, domain, password, ontologyCellURL, project); HttpClient httpClient = HttpClients.createDefault(); traversePaths.printPath(httpClient, null, 0, depth); } catch (I2B2InterfaceException | JAXBException | IOException e) { System.out.println("An error occurred traverse the paths"); e.printStackTrace(); } System.out.println("\nFinished with " + traversePaths.getTotalCount() + " returned in total"); }