List of usage examples for java.lang Integer valueOf
@HotSpotIntrinsicCandidate public static Integer valueOf(int i)
From source file:cz.alej.michalik.totp.util.TOTP.java
/** * Ukzka TOTP pro zprvu "12345678901234567890" */// w w w . j a v a 2s .c om public static void main(String[] args) { // GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ v base32 String secret = "12345678901234567890"; System.out.printf("Heslo je: %s \nV Base32 to je: %s\n", secret, new Base32().encodeToString(secret.getBytes())); TOTP t = new TOTP(secret.getBytes()); System.out.printf("%s\n", t); while (true) { int time = Integer.valueOf(new SimpleDateFormat("ss").format(new Date())); if (time % 30 == 0) { System.out.printf("%s\n", t); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:com.sm.test.TestClusterClient.java
public static void main(String[] args) throws Exception { String[] opts = new String[] { "-configPath", "-url", "-store", "-times", "-nio", "-size" }; String[] defaults = new String[] { "", "localhost:7100", "store", "2", "true", "2000" }; String[] paras = getOpts(args, opts, defaults); String configPath = paras[0]; if (configPath.length() == 0) { //logger.error("missing config path or host"); //throw new RuntimeException("missing -configPath or -host"); }//from w w w . j a v a 2 s .c om String url = paras[1]; String store = paras[2]; int times = Integer.valueOf(paras[3]); boolean nio = Boolean.valueOf(paras[4]); int size = Integer.valueOf(paras[5]); ClusterClientFactory ccf = ClusterClientFactory.connect(url, store, new HessianSerializer(), TCPClientFactory.ClientType.Netty); ClusterClient client = ccf.getDefaultStore(3000); TestClusterClient testClient = new TestClusterClient(client); client.put(Key.createKey("test-0"), "test-0"); testClient.testMultiPut(500); testClient.testMultiGet(500); testClient.testScan(500); testClient.testScanCursor(500); Value v = client.get(Key.createKey("test-0")); System.out.println(v.getData()); //ccf.reloadClusterClient(); client.close(); ccf.close(); }
From source file:com.github.houbin217jz.thumbnail.Thumbnail.java
public static void main(String[] args) { Options options = new Options(); options.addOption("s", "src", true, "????????????"); options.addOption("d", "dst", true, ""); options.addOption("r", "ratio", true, "/??, 30%???0.3????????"); options.addOption("w", "width", true, "(px)"); options.addOption("h", "height", true, "?(px)"); options.addOption("R", "recursive", false, "???????"); HelpFormatter formatter = new HelpFormatter(); String formatstr = "java -jar thumbnail.jar " + "[-s/--src <path>] " + "[-d/--dst <path>] " + "[-r/--ratio double] " + "[-w/--width integer] " + "[-h/--height integer] " + "[-R/--recursive] "; CommandLineParser parser = new PosixParser(); CommandLine cmd = null;/*from w ww . j a v a 2 s . c om*/ try { cmd = parser.parse(options, args); } catch (ParseException e1) { formatter.printHelp(formatstr, options); return; } final Path srcDir, dstDir; final Integer width, height; final Double ratio; // if (cmd.hasOption("s")) { srcDir = Paths.get(cmd.getOptionValue("s")).toAbsolutePath(); } else { srcDir = Paths.get("").toAbsolutePath(); //?? } // if (cmd.hasOption("d")) { dstDir = Paths.get(cmd.getOptionValue("d")).toAbsolutePath(); } else { formatter.printHelp(formatstr, options); return; } if (!Files.exists(srcDir, LinkOption.NOFOLLOW_LINKS) || !Files.isDirectory(srcDir, LinkOption.NOFOLLOW_LINKS)) { System.out.println("[" + srcDir.toAbsolutePath() + "]??????"); return; } if (Files.exists(dstDir, LinkOption.NOFOLLOW_LINKS)) { if (!Files.isDirectory(dstDir, LinkOption.NOFOLLOW_LINKS)) { //???????? System.out.println("????????"); return; } } else { //???????? try { Files.createDirectories(dstDir); } catch (IOException e) { e.printStackTrace(); return; } } //?? if (cmd.hasOption("w") && cmd.hasOption("h")) { try { width = Integer.valueOf(cmd.getOptionValue("width")); height = Integer.valueOf(cmd.getOptionValue("height")); } catch (NumberFormatException e) { System.out.println("??????"); return; } } else { width = null; height = null; } //? if (cmd.hasOption("r")) { try { ratio = Double.valueOf(cmd.getOptionValue("r")); } catch (NumberFormatException e) { System.out.println("?????"); return; } } else { ratio = null; } if (width != null && ratio != null) { System.out.println("??????????????"); return; } if (width == null && ratio == null) { System.out.println("????????????"); return; } // int maxDepth = 1; if (cmd.hasOption("R")) { maxDepth = Integer.MAX_VALUE; } try { //Java 7 ??@see http://docs.oracle.com/javase/jp/7/api/java/nio/file/Files.html Files.walkFileTree(srcDir, EnumSet.of(FileVisitOption.FOLLOW_LINKS), maxDepth, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes) throws IOException { //???&??? String filename = path.getFileName().toString().toLowerCase(); if (filename.endsWith(".jpg") || filename.endsWith(".jpeg")) { //Jpeg?? /* * relative??: * rootPath: /a/b/c/d * filePath: /a/b/c/d/e/f.jpg * rootPath.relativize(filePath) = e/f.jpg */ /* * resolve?? * rootPath: /a/b/c/output * relativePath: e/f.jpg * rootPath.resolve(relativePath) = /a/b/c/output/e/f.jpg */ Path dst = dstDir.resolve(srcDir.relativize(path)); if (!Files.exists(dst.getParent(), LinkOption.NOFOLLOW_LINKS)) { Files.createDirectories(dst.getParent()); } doResize(path.toFile(), dst.toFile(), width, height, ratio); } return FileVisitResult.CONTINUE; } }); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.baidu.rigel.biplatform.ma.file.serv.FileServer.java
/** * /*from www. j a v a 2 s .c om*/ * ???server * * @param args */ public static void main(String[] args) throws Exception { // if (args.length != 1) { // LOGGER.error("can not get enough parameters for starting file server"); // printUsage(); // System.exit(-1); // } FileInputStream fis = null; String classLocation = FileServer.class.getProtectionDomain().getCodeSource().getLocation().toString(); final File configFile = new File(classLocation + "/../conf/fileserver.conf"); Properties properties = new Properties(); try { if (configFile.exists()) { fis = new FileInputStream(configFile); } else if (StringUtils.isNotEmpty(args[0])) { fis = new FileInputStream(args[0]); } else { printUsage(); throw new RuntimeException("can't find correct file server configuration file!"); } properties.load(fis); } finally { if (fis != null) { fis.close(); } } int port = -1; try { port = Integer.valueOf(properties.getProperty(PORT_NUM_KEY)); } catch (NumberFormatException e) { LOGGER.error("parameter is not correct, [port = {}]", args[0]); System.exit(-1); } String location = properties.getProperty(ROOT_DIR_KEY); if (StringUtils.isEmpty(location)) { LOGGER.error("the location can not be empty"); System.exit(-1); } File f = new File(location); if (!f.exists() && !f.mkdirs()) { LOGGER.error("invalidation location [{}] please verify the input", args[1]); System.exit(-1); } startServer(location, port); }
From source file:backtype.storm.command.gray_upgrade.java
public static void main(String[] args) throws Exception { if (args == null || args.length < 1) { System.out.println("Invalid parameter"); usage();// w w w .j ava 2 s . c o m return; } String topologyName = args[0]; String[] str2 = Arrays.copyOfRange(args, 1, args.length); CommandLineParser parser = new GnuParser(); Options r = buildGeneralOptions(new Options()); CommandLine commandLine = parser.parse(r, str2, true); int workerNum = 0; String component = null; List<String> workers = null; if (commandLine.hasOption("n")) { workerNum = Integer.valueOf(commandLine.getOptionValue("n")); } if (commandLine.hasOption("p")) { component = commandLine.getOptionValue("p"); } if (commandLine.hasOption("w")) { String w = commandLine.getOptionValue("w"); if (!StringUtils.isBlank(w)) { workers = Lists.newArrayList(); String[] parts = w.split(","); for (String part : parts) { if (part.split(":").length == 2) { workers.add(part.trim()); } } } } upgradeTopology(topologyName, component, workers, workerNum); }
From source file:de.huberlin.wbi.cuneiform.cmdline.main.Main.java
public static void main(String[] args) throws IOException, ParseException, InterruptedException, NotDerivableException { CommandLine cmd;/* w w w . j av a2 s . com*/ Options opt; BaseRepl repl; BaseCreActor cre; Path sandbox; ExecutorService executor; TicketSrcActor ticketSrc; JsonSummary summary; Path summaryPath; Log statLog; int nthread; Path workDir; statLog = LogFactory.getLog("statLogger"); executor = Executors.newCachedThreadPool(); try { opt = getOptions(); cmd = parse(args, opt); config(cmd); if (cmd.hasOption('h')) { System.out.println("CUNEIFORM - A Functional Workflow Language\nversion " + BaseRepl.LABEL_VERSION + " build " + BaseRepl.LABEL_BUILD); new HelpFormatter().printHelp("java -jar cuneiform.jar [OPTION]*", opt); return; } if (cmd.hasOption('r')) Invocation.putLibPath(ForeignLambdaExpr.LANGID_R, cmd.getOptionValue('r')); if (cmd.hasOption('y')) Invocation.putLibPath(ForeignLambdaExpr.LANGID_PYTHON, cmd.getOptionValue('y')); if (cmd.hasOption('l')) sandbox = Paths.get(cmd.getOptionValue("l")); else sandbox = Paths.get(System.getProperty("user.home")).resolve(".cuneiform"); sandbox = sandbox.toAbsolutePath(); if (cmd.hasOption('c')) LocalThread.deleteIfExists(sandbox); if (cmd.hasOption('t')) nthread = Integer.valueOf(cmd.getOptionValue('t')); else nthread = Runtime.getRuntime().availableProcessors(); if (cmd.hasOption('w')) workDir = Paths.get(cmd.getOptionValue('w')); else workDir = Paths.get(System.getProperty("user.dir")); workDir = workDir.toAbsolutePath(); switch (platform) { case PLATFORM_LOCAL: if (!Files.exists(sandbox)) Files.createDirectories(sandbox); cre = new LocalCreActor(sandbox, workDir, nthread); break; case PLATFORM_HTCONDOR: if (!Files.exists(sandbox)) Files.createDirectories(sandbox); if (cmd.hasOption('m')) { // MAX_TRANSFER SIZE String maxTransferSize = cmd.getOptionValue('m'); try { cre = new CondorCreActor(sandbox, maxTransferSize); } catch (Exception e) { System.out.println("INVALID '-m' option value: " + maxTransferSize + "\n\nCUNEIFORM - A Functional Workflow Language\nversion " + BaseRepl.LABEL_VERSION + " build " + BaseRepl.LABEL_BUILD); new HelpFormatter().printHelp("java -jar cuneiform.jar [OPTION]*", opt); return; } } else { cre = new CondorCreActor(sandbox); } break; default: throw new RuntimeException("Platform not recognized."); } executor.submit(cre); ticketSrc = new TicketSrcActor(cre); executor.submit(ticketSrc); executor.shutdown(); switch (format) { case FORMAT_CF: if (cmd.hasOption("i")) repl = new InteractiveRepl(ticketSrc, statLog); else repl = new CmdlineRepl(ticketSrc, statLog); break; case FORMAT_DAX: repl = new DaxRepl(ticketSrc, statLog); break; default: throw new RuntimeException("Format not recognized."); } if (cmd.hasOption("i")) { // run in interactive mode BaseRepl.run(repl); return; } // run in quiet mode if (inputFileVector.length > 0) for (Path f : inputFileVector) repl.interpret(readFile(f)); else repl.interpret(readStdIn()); Thread.sleep(3 * Actor.DELAY); while (repl.isBusy()) Thread.sleep(Actor.DELAY); if (cmd.hasOption("s")) { summary = new JsonSummary(ticketSrc.getRunId(), sandbox, repl.getAns()); summaryPath = Paths.get(cmd.getOptionValue("s")); summaryPath = summaryPath.toAbsolutePath(); try (BufferedWriter writer = Files.newBufferedWriter(summaryPath, Charset.forName("UTF-8"))) { writer.write(summary.toString()); } } } finally { executor.shutdownNow(); } }
From source file:org.ala.harvester.MorphbankHarvester.java
/** * Main method for testing this particular Harvester * * @param args/* ww w. ja v a 2 s .c om*/ */ public static void main(String[] args) throws Exception { String[] locations = { "classpath*:spring.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(locations); MorphbankHarvester h = new MorphbankHarvester(); Repository r = (Repository) context.getBean("repository"); h.setRepository(r); //set the connection params Map<String, String> connectParams = new HashMap<String, String>(); if (args.length == 1 && args[0].equals("Coral")) { h.setCoral(true); connectParams.put("endpoint", "http://morphbank-svc.ala.org.au/mb3/request?method=search&objecttype=Image&keywords=Coral+Reef+Research&limit=" + RESULT_LIMIT + "&firstResult=0&user=&group=&change=&lastDateChanged=&numChangeDays=1&id=&taxonName=&format=svc"); } else if (args.length == 1) { connectParams.put("endpoint", "http://morphbank-svc.ala.org.au/mb3/request?method=search&objecttype=Image&keywords=Australia&limit=" + RESULT_LIMIT + "&firstResult=0&user=&group=&change=&lastDateChanged=&numChangeDays=1&id=&taxonName=&format=svc"); try { h.setInit(Integer.valueOf(args[0])); } catch (NumberFormatException nfe) { System.out.println("Starting id is not a number!"); System.exit(1); } } else { connectParams.put("endpoint", "http://morphbank-svc.ala.org.au/mb3/request?method=search&objecttype=Image&keywords=Australia&limit=" + RESULT_LIMIT + "&firstResult=0&user=&group=&change=&lastDateChanged=&numChangeDays=1&id=&taxonName=&format=svc"); } h.setConnectionParams(connectParams); h.start(MORPHBANK_INFOSOURCE_ID); }
From source file:com.antbrains.crf.hadoop.CalcFeatureWeights.java
public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); if (otherArgs.length != 3 && otherArgs.length != 4) { System.err.println("CalcFeatureWeights <inDir> <tmpDir> <outDir> [startStep]"); System.exit(-1);//from w w w. jav a 2 s . c o m } int startStep = 1; if (otherArgs.length == 4) { startStep = Integer.valueOf(otherArgs[otherArgs.length - 1]); } FileSystem fs = FileSystem.get(conf); if (startStep <= 1) { System.out.println("calc"); fs.delete(new Path(otherArgs[1]), true); Job job = new Job(conf, CalcFeatureWeights.class.getSimpleName()); job.setNumReduceTasks(1); job.setJarByClass(CalcFeatureWeights.class); job.setMapperClass(CalcFeatureMapper.class); job.setReducerClass(CalcFeatureReducer.class); job.setOutputFormatClass(SequenceFileOutputFormat.class); job.setInputFormatClass(SequenceFileInputFormat.class); job.setMapOutputKeyClass(IntWritable.class); job.setMapOutputValueClass(MyKey.class); job.setOutputKeyClass(MyKey.class); job.setOutputValueClass(MyValue.class); FileInputFormat.setInputPaths(job, new Path(otherArgs[0])); FileOutputFormat.setOutputPath(job, new Path(otherArgs[1])); boolean res = job.waitForCompletion(true); if (!res) { System.err.println("step1 failed"); return; } } if (startStep <= 2) // sort { fs.delete(new Path(otherArgs[2]), true); System.out.println("sort"); Job job = new Job(conf, CalcFeatureWeights.class.getSimpleName()); job.setNumReduceTasks(1); job.setJarByClass(CalcFeatureWeights.class); job.setMapperClass(IdentityMapper.class); job.setReducerClass(IdentityReducer.class); job.setOutputFormatClass(SequenceFileOutputFormat.class); job.setInputFormatClass(SequenceFileInputFormat.class); job.setMapOutputKeyClass(MyKey.class); job.setMapOutputValueClass(MyValue.class); job.setOutputKeyClass(MyKey.class); job.setOutputValueClass(MyValue.class); FileInputFormat.setInputPaths(job, new Path(otherArgs[1])); FileOutputFormat.setOutputPath(job, new Path(otherArgs[2])); boolean res = job.waitForCompletion(true); if (!res) { System.err.println("step2 failed"); return; } } }
From source file:de.fischer.thotti.core.runner.NDRunner.java
/** * Main method of the {@link NDRunner}./*from www . ja v a 2 s . c o m*/ */ public static void main(String[] args) throws IOException { try { // @todo Evaluate --jopt-simple Options options = createCommandLineOption(); CommandLineParser parser = new GnuParser(); try { // parse the command line arguments org.apache.commons.cli.CommandLine line = parser.parse(options, args); if (line.hasOption("slave")) { if (!line.hasOption("executionid")) { throw new ParseException("Execution id is missing."); } String eid = line.getOptionValue("executionid"); int eidInt = Integer.valueOf(eid); new NDRunner().runSlaveMode(eidInt); } else { new NDRunner().runMasterMode(); } } catch (ParseException exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); } } catch (RunnerException e) { if (e.getCause() != null) { e.printStackTrace(System.err); System.err.println(); } System.err.println(e.getMessage()); System.exit(ERROR); } }
From source file:ListHeap.java
public static void main(String[] args) { Heap heap = new ListHeap(5); for (int ai = 0; ai < args.length; ai++) { heap.add(Integer.valueOf(Integer.parseInt(args[ai]))); }/*from ww w . j av a 2s .co m*/ while (!heap.isEmpty()) { System.out.print(heap.extract() + " "); } System.out.println(); }