List of usage examples for java.util Arrays toString
public static String toString(Object[] a)
From source file:ConsumerTool.java
public static void main(String[] args) { ArrayList<ConsumerTool> threads = new ArrayList(); ConsumerTool consumerTool = new ConsumerTool(); String[] unknown = CommandLineSupport.setOptions(consumerTool, args); if (unknown.length > 0) { System.out.println("Unknown options: " + Arrays.toString(unknown)); System.exit(-1);// w w w . ja va 2 s .c om } consumerTool.showParameters(); for (int threadCount = 1; threadCount <= parallelThreads; threadCount++) { consumerTool = new ConsumerTool(); CommandLineSupport.setOptions(consumerTool, args); consumerTool.start(); threads.add(consumerTool); } while (true) { Iterator<ConsumerTool> itr = threads.iterator(); int running = 0; while (itr.hasNext()) { ConsumerTool thread = itr.next(); if (thread.isAlive()) { running++; } } if (running <= 0) { System.out.println("All threads completed their work"); break; } try { Thread.sleep(1000); } catch (Exception e) { } } Iterator<ConsumerTool> itr = threads.iterator(); while (itr.hasNext()) { ConsumerTool thread = itr.next(); } }
From source file:org.sbq.batch.mains.ActivityEmulator.java
public static void main(String[] vars) throws IOException { System.out.println("ActivityEmulator - STARTED."); ActivityEmulator activityEmulator = new ActivityEmulator(); activityEmulator.begin();//from www .j a va2 s .c o m System.out.println("Enter your command: >"); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String command = null; while (!"stop".equals(command = in.readLine())) { if ("status".equals(command)) { List<String> onlineUsers = new LinkedList<String>(); for (Map.Entry<String, AtomicBoolean> entry : activityEmulator.getUserStatusByLogin().entrySet()) { if (entry.getValue().get()) { onlineUsers.add(entry.getKey()); } } System.out.println("Users online: " + Arrays.toString(onlineUsers.toArray())); System.out.println("Number of cycles left: " + activityEmulator.getBlockingQueue().size()); } System.out.println("Enter your command: >"); } activityEmulator.stop(); System.out.println("ActivityEmulator - STOPPED."); }
From source file:gdv.xport.Main.java
/** * Diese Main-Klasse dient hautpsaechlich zu Demo-Zwecken. Werden keine Optionen angegeben, wird von der * Standard-Eingabe (System.in) gelesen und das Ergebnis nach System.out geschrieben. <br/> * Mit "-help" bekommt man eine kleine Uebersicht der Optionen. * * @param args// www. jav a 2 s .c o m * die verschiendene Argumente (z.B. -import * http://www.gdv-online.de/vuvm/musterdatei_bestand/musterdatei_041222.txt -validate -xml) * @throws IOException * falls der Import oder Export schief gegangen ist * @throws XMLStreamException * falls bei der XML-Generierung was schief gelaufen ist. */ public static void main(final String[] args) throws IOException, XMLStreamException { Options options = createOptions(); CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); // Option "-help" if (cmd.hasOption("help")) { printHelp(options); System.exit(0); } Datenpaket datenpaket = importDatenpaket(cmd); formatDatenpaket(cmd, datenpaket); // Option "-validate" if (cmd.hasOption("validate")) { printViolations(datenpaket.validate()); } } catch (ParseException ex) { LOG.log(Level.SEVERE, "Cannot parse " + Arrays.toString(args), ex); System.err.println("Fehler beim Aufruf von " + Main.class); printHelp(options); System.exit(1); } }
From source file:ar.com.ergio.uncoma.cei.MiniPas.java
/** * @param args/*from w ww . ja v a 2 s . co m*/ * @throws IOException */ @SuppressWarnings("static-access") public static void main(String[] args) throws IOException { // Config logging system -- TODO improve this Handler console = new ConsoleHandler(); ROOT_LOG.addHandler(console); // Create cmdline options - TODO - I18N final Options options = new Options(); options.addOption(new Option("help", "Muestra este mensaje")); options.addOption(new Option("version", "Muestra la informaci\u00f3 de versi\u00f3n y termina")); options.addOption(new Option("debug", "Muestra informaci\u00f3n para depuraci\u00f3n")); options.addOption( OptionBuilder.withArgName("file").hasArg().withDescription("Archivo de log").create("logFile")); final CommandLineParser cmdlineParser = new GnuParser(); final HelpFormatter formatter = new HelpFormatter(); try { final CommandLine cmdline = cmdlineParser.parse(options, args); // Process command line args -- TODO Improve this if (args.length == 0 || cmdline.hasOption("help")) { formatter.printHelp("minipas", options, true); } else if (cmdline.hasOption("version")) { System.out.println("MiniPas versi\u00f3n: 0.0.1"); } else if (cmdline.hasOption("debug")) { ROOT_LOG.setLevel(Level.FINE); } else { ROOT_LOG.fine("Arguments: " + Arrays.toString(args)); final Scanner scanner = new Scanner(args[0]); while (scanner.hasTokens()) { System.out.println(scanner.nextToken()); } } } catch (ParseException e) { formatter.printHelp("minipas", options, true); } }
From source file:SequentialPageRank.java
@SuppressWarnings({ "static-access" }) public static void main(String[] args) throws IOException { Options options = new Options(); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT)); options.addOption(/*w w w. j ava2 s . c o m*/ OptionBuilder.withArgName("val").hasArg().withDescription("random jump factor").create(JUMP)); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(INPUT)) { System.out.println("args: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(SequentialPageRank.class.getName(), options); ToolRunner.printGenericCommandUsage(System.out); System.exit(-1); } String infile = cmdline.getOptionValue(INPUT); float alpha = cmdline.hasOption(JUMP) ? Float.parseFloat(cmdline.getOptionValue(JUMP)) : 0.15f; int edgeCnt = 0; DirectedSparseGraph<String, Integer> graph = new DirectedSparseGraph<String, Integer>(); BufferedReader data = new BufferedReader(new InputStreamReader(new FileInputStream(infile))); String line; while ((line = data.readLine()) != null) { line.trim(); String[] arr = line.split("\\t"); for (int i = 1; i < arr.length; i++) { graph.addEdge(new Integer(edgeCnt++), arr[0], arr[i]); } } data.close(); WeakComponentClusterer<String, Integer> clusterer = new WeakComponentClusterer<String, Integer>(); Set<Set<String>> components = clusterer.transform(graph); int numComponents = components.size(); System.out.println("Number of components: " + numComponents); System.out.println("Number of edges: " + graph.getEdgeCount()); System.out.println("Number of nodes: " + graph.getVertexCount()); System.out.println("Random jump factor: " + alpha); // Compute PageRank. PageRank<String, Integer> ranker = new PageRank<String, Integer>(graph, alpha); ranker.evaluate(); // Use priority queue to sort vertices by PageRank values. PriorityQueue<Ranking<String>> q = new PriorityQueue<Ranking<String>>(); int i = 0; for (String pmid : graph.getVertices()) { q.add(new Ranking<String>(i++, ranker.getVertexScore(pmid), pmid)); } // Print PageRank values. System.out.println("\nPageRank of nodes, in descending order:"); Ranking<String> r = null; while ((r = q.poll()) != null) { System.out.println(r.rankScore + "\t" + r.getRanked()); } }
From source file:net.opentsdb.ConfigReader.java
public static void main(String[] args) { System.setProperty("capsule.cache.dir", "/tmp"); try {/* w w w . j a va 2 s . c om*/ final Config config = new Config(false); String[] cmdLineArgs = load(config, new String[] { "--port", "3847" }); System.out.println("CMD Line Args:" + Arrays.toString(cmdLineArgs)); System.out.println("TSDB Config:" + config.dumpConfiguration()); } catch (Exception ex) { ex.printStackTrace(System.err); throw new RuntimeException(ex); } }
From source file:de.serverfrog.pw.crypt.SerpentUtil.java
/** * Print all Security providers and their algos * * @param args args// www . j av a 2 s . com * @throws Exception Exception */ public static void main(String[] args) throws Exception { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); SecretKeySpec keySpec = new SecretKeySpec("test".getBytes("UTF-8"), "AES"); try (CipherOutputStream outputStream = SerpentUtil.getOutputStream(byteArrayOutputStream, keySpec)) { IOUtils.write("TEST", outputStream); } System.out.println(Arrays.toString(byteArrayOutputStream.toByteArray())); System.out.println(byteArrayOutputStream.toString("UTF-8")); byte[] toByteArray = byteArrayOutputStream.toByteArray(); ByteArrayInputStream arrayInputStream = new ByteArrayInputStream(toByteArray); CipherInputStream inputStream = SerpentUtil.getInputStream(arrayInputStream, new SecretKeySpec("test".getBytes("UTF-8"), "AES")); byte[] bytes = new byte[1048576]; IOUtils.read(inputStream, bytes); System.out.println(new String(bytes, "UTF-8").trim()); // // for (Provider provider : Security.getProviders()) { // System.out.println(""); // System.out.println(""); // System.out.println(""); // System.out.println("-------------------------------"); // System.out.println("Name: " + provider.getName()); // System.out.println("Info: " + provider.getInfo()); // for (Map.Entry<Object, Object> entry : provider.entrySet()) { // System.out.println("Key: Class:" + entry.getKey().getClass() + " String: " + entry.getKey()); // System.out.println("Value: Class:" + entry.getValue().getClass() + " String: " + entry.getValue()); // } // for (Provider.Service service : provider.getServices()) { // System.out.println("Service: Algorithm:" + service.getAlgorithm() // + " ClassName:" + service.getClassName() // + " Type:" + service.getType() + " toString:" + service.toString()); // } // for (Object object : provider.values()) { // System.out.println("Value: " + object.getClass() + " toString:" + object.toString()); // // } // System.out.println("-------------------------------"); // } }
From source file:com.github.enr.markdownj.extras.MarkdownApp.java
public static void main(String[] args) { MarkdownApp app = new MarkdownApp(); app.log().debug("Markdown app starting with args: {}", Arrays.toString(args)); CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption("s", "source", true, "The source directory for markdown files"); options.addOption("d", "destination", true, "The destination directory for html files"); options.addOption("h", "header", true, "The path to the html header file"); options.addOption("f", "footer", true, "The path to the html footer file"); options.addOption("t", "code-template", true, "The template for code blocks"); options.addOption("e", "extensions", true, "A comma separated list of file extensions to process. If setted, files with extension not in list won't be processed"); options.addOption("c", "char-encoding", true, "The encoding to read and write files"); HelpFormatter formatter = new HelpFormatter(); String helpHeader = String.format("%s", MarkdownApp.class.getName()); try {// w ww . j a va 2 s . c o m CommandLine line = parser.parse(options, args); app.process(line); } catch (ParseException e) { app.log().warn(e.getMessage(), e); formatter.printHelp(helpHeader, options); } }
From source file:SequentialPersonalizedPageRank.java
@SuppressWarnings({ "static-access" }) public static void main(String[] args) throws IOException { Options options = new Options(); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT)); options.addOption(/*w w w . ja v a2 s .c o m*/ OptionBuilder.withArgName("val").hasArg().withDescription("random jump factor").create(JUMP)); options.addOption(OptionBuilder.withArgName("node").hasArg() .withDescription("source node (i.e., destination of the random jump)").create(SOURCE)); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(INPUT) || !cmdline.hasOption(SOURCE)) { System.out.println("args: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(SequentialPersonalizedPageRank.class.getName(), options); ToolRunner.printGenericCommandUsage(System.out); System.exit(-1); } String infile = cmdline.getOptionValue(INPUT); final String source = cmdline.getOptionValue(SOURCE); float alpha = cmdline.hasOption(JUMP) ? Float.parseFloat(cmdline.getOptionValue(JUMP)) : 0.15f; int edgeCnt = 0; DirectedSparseGraph<String, Integer> graph = new DirectedSparseGraph<String, Integer>(); BufferedReader data = new BufferedReader(new InputStreamReader(new FileInputStream(infile))); String line; while ((line = data.readLine()) != null) { line.trim(); String[] arr = line.split("\\t"); for (int i = 1; i < arr.length; i++) { graph.addEdge(new Integer(edgeCnt++), arr[0], arr[i]); } } data.close(); if (!graph.containsVertex(source)) { System.err.println("Error: source node not found in the graph!"); System.exit(-1); } WeakComponentClusterer<String, Integer> clusterer = new WeakComponentClusterer<String, Integer>(); Set<Set<String>> components = clusterer.transform(graph); int numComponents = components.size(); System.out.println("Number of components: " + numComponents); System.out.println("Number of edges: " + graph.getEdgeCount()); System.out.println("Number of nodes: " + graph.getVertexCount()); System.out.println("Random jump factor: " + alpha); // Compute personalized PageRank. PageRankWithPriors<String, Integer> ranker = new PageRankWithPriors<String, Integer>(graph, new Transformer<String, Double>() { @Override public Double transform(String vertex) { return vertex.equals(source) ? 1.0 : 0; } }, alpha); ranker.evaluate(); // Use priority queue to sort vertices by PageRank values. PriorityQueue<Ranking<String>> q = new PriorityQueue<Ranking<String>>(); int i = 0; for (String pmid : graph.getVertices()) { q.add(new Ranking<String>(i++, ranker.getVertexScore(pmid), pmid)); } // Print PageRank values. System.out.println("\nPageRank of nodes, in descending order:"); Ranking<String> r = null; while ((r = q.poll()) != null) { System.out.println(r.rankScore + "\t" + r.getRanked()); } }
From source file:edu.umd.shrawanraina.SequentialPersonalizedPageRank.java
@SuppressWarnings({ "static-access" }) public static void main(String[] args) throws IOException { Options options = new Options(); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT)); options.addOption(/*from w w w . j av a 2s . c o m*/ OptionBuilder.withArgName("val").hasArg().withDescription("random jump factor").create(JUMP)); options.addOption(OptionBuilder.withArgName("node").hasArg() .withDescription("source node (i.e., destination of the random jump)").create(SOURCE)); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(INPUT) || !cmdline.hasOption(SOURCE)) { System.out.println("args: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(120); formatter.printHelp(SequentialPersonalizedPageRank.class.getName(), options); ToolRunner.printGenericCommandUsage(System.out); System.exit(-1); } String infile = cmdline.getOptionValue(INPUT); final String source = cmdline.getOptionValue(SOURCE); float alpha = cmdline.hasOption(JUMP) ? Float.parseFloat(cmdline.getOptionValue(JUMP)) : 0.15f; int edgeCnt = 0; DirectedSparseGraph<String, Integer> graph = new DirectedSparseGraph<String, Integer>(); BufferedReader data = new BufferedReader(new InputStreamReader(new FileInputStream(infile))); String line; while ((line = data.readLine()) != null) { line.trim(); String[] arr = line.split("\\t"); for (int i = 1; i < arr.length; i++) { graph.addEdge(new Integer(edgeCnt++), arr[0], arr[i]); } } data.close(); if (!graph.containsVertex(source)) { System.err.println("Error: source node not found in the graph!"); System.exit(-1); } WeakComponentClusterer<String, Integer> clusterer = new WeakComponentClusterer<String, Integer>(); Set<Set<String>> components = clusterer.transform(graph); int numComponents = components.size(); System.out.println("Number of components: " + numComponents); System.out.println("Number of edges: " + graph.getEdgeCount()); System.out.println("Number of nodes: " + graph.getVertexCount()); System.out.println("Random jump factor: " + alpha); // Compute personalized PageRank. PageRankWithPriors<String, Integer> ranker = new PageRankWithPriors<String, Integer>(graph, new Transformer<String, Double>() { public Double transform(String vertex) { return vertex.equals(source) ? 1.0 : 0; } }, alpha); ranker.evaluate(); // Use priority queue to sort vertices by PageRank values. PriorityQueue<Ranking<String>> q = new PriorityQueue<Ranking<String>>(); int i = 0; for (String pmid : graph.getVertices()) { q.add(new Ranking<String>(i++, ranker.getVertexScore(pmid), pmid)); } // Print PageRank values. System.out.println("\nPageRank of nodes, in descending order:"); Ranking<String> r = null; while ((r = q.poll()) != null) { System.out.println(r.rankScore + "\t" + r.getRanked()); } }