List of usage examples for java.io PrintStream format
public PrintStream format(String format, Object... args)
From source file:Main.java
public static void main(String[] args) { String s = "from java2s.com"; PrintStream ps = new PrintStream(System.out); // format a string ps.format("This is a %s program", s); // flush the stream ps.flush();/*w w w. ja va 2 s . c om*/ }
From source file:com.google.testing.pogen.PageObjectGenerator.java
/** * Prints the usage of the PageObjectGenerator with the specified {@link PrintStream} instance. * // w w w. ja v a 2 s. c o m * @param printStream the {@link PrintStream} to print */ private static void printUsage(PrintStream printStream) { printStream.println("usage: java PageObjectGenerator COMMAND [ARGS]"); printStream.println("The commands are:"); printStream.format(" %-10s Generate modified templates and skeleton test code\n", GENERATE_COMMAND); printStream.format(" %-10s Measure template-variable coverage\n", MEASURE_COMMAND); printStream.format(" %-10s List template variables and ids\n", LIST_COMMAND); }
From source file:codesample.AuthenticationSample.java
/***************************************************************************************************************** * * Prints a log message to stderr.//w w w . jav a 2 s. c om * * @param format A string which formats how args will be displayed in the message. * @param args List of objects to be displayed in the message. * ***************************************************************************************************************** */ public static void logMessage(String format, Object... args) { // Change output stream if desired PrintStream logStream = System.err; logStream.format(logTime() + " " + format + "%n", args); }
From source file:Java_BWS_Sample.SampleBwsClient.java
/******************************************************************************************************************* * * Prints a log message to stderr./*from www .ja v a2s . co m*/ * Appends the message to a string containing the elapsed time of the program. * * @param format - A string which formats how args will be displayed in the message. * @param args - List of objects to be displayed in the message. * ******************************************************************************************************************* */ public static void logMessage(String format, Object... args) { //Change output stream if desired PrintStream logStream = System.err; logStream.format(logTime() + " " + format + "%n", args); }
From source file:Java_BWS_Sample.SampleBwsClient.java
/******************************************************************************************************************* * * Prints results to stderr./*w w w .ja va 2 s. c o m*/ * * @param format - A string which formats how args will be displayed in the message. * @param args - List of objects to be displayed in the message. * ******************************************************************************************************************* */ public static void displayResult(String format, Object... args) { //Change output stream if desired PrintStream resultStream = System.err; for (Object arg : args) { //Do not display null values if (arg == null) { return; } } resultStream.format(format + "%n", args); }
From source file:io.takari.maven.testing.executor.ForkedLauncher.java
public int run(String[] cliArgs, Map<String, String> envVars, File multiModuleProjectDirectory, File workingDirectory, File logFile) throws IOException, LauncherException { String javaHome;//from www . j av a2 s .c o m if (envVars == null || envVars.get("JAVA_HOME") == null) { javaHome = System.getProperty("java.home"); } else { javaHome = envVars.get("JAVA_HOME"); } File executable = new File(javaHome, Os.isFamily(Os.FAMILY_WINDOWS) ? "bin/javaw.exe" : "bin/java"); CommandLine cli = new CommandLine(executable); cli.addArgument("-classpath").addArgument(classworldsJar.getAbsolutePath()); cli.addArgument("-Dclassworlds.conf=" + new File(mavenHome, "bin/m2.conf").getAbsolutePath()); cli.addArgument("-Dmaven.home=" + mavenHome.getAbsolutePath()); cli.addArgument("-Dmaven.multiModuleProjectDirectory=" + multiModuleProjectDirectory.getAbsolutePath()); cli.addArgument("org.codehaus.plexus.classworlds.launcher.Launcher"); cli.addArguments(args.toArray(new String[args.size()])); if (extensions != null && !extensions.isEmpty()) { cli.addArgument("-Dmaven.ext.class.path=" + toPath(extensions)); } cli.addArguments(cliArgs); Map<String, String> env = new HashMap<>(); if (mavenHome != null) { env.put("M2_HOME", mavenHome.getAbsolutePath()); } if (envVars != null) { env.putAll(envVars); } if (envVars == null || envVars.get("JAVA_HOME") == null) { env.put("JAVA_HOME", System.getProperty("java.home")); } DefaultExecutor executor = new DefaultExecutor(); executor.setProcessDestroyer(new ShutdownHookProcessDestroyer()); executor.setWorkingDirectory(workingDirectory.getAbsoluteFile()); try (OutputStream log = new FileOutputStream(logFile)) { PrintStream out = new PrintStream(log); out.format("Maven Executor implementation: %s\n", getClass().getName()); out.format("Maven home: %s\n", mavenHome); out.format("Build work directory: %s\n", workingDirectory); out.format("Environment: %s\n", env); out.format("Command line: %s\n\n", cli.toString()); out.flush(); PumpStreamHandler streamHandler = new PumpStreamHandler(log); executor.setStreamHandler(streamHandler); return executor.execute(cli, env); // this throws ExecuteException if process return code != 0 } catch (ExecuteException e) { throw new LauncherException("Failed to run Maven: " + e.getMessage() + "\n" + cli, e); } }
From source file:com.at.lic.LicenseControl.java
private String getMAC() throws Exception { String mac = "1:2:3:4:5:6:7:8"; // default mac address InetAddress addr = InetAddress.getLocalHost(); NetworkInterface ni = NetworkInterface.getByInetAddress(addr); if (ni.isLoopback() || ni.isVirtual()) { ni = null;/*from w w w. j ava 2 s.c om*/ Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces(); while (nis.hasMoreElements()) { NetworkInterface aNI = (NetworkInterface) nis.nextElement(); if (!aNI.isLoopback() && !aNI.isVirtual()) { ni = aNI; break; } } } if (ni != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); byte[] HAs = ni.getHardwareAddress(); for (int i = 0; i < HAs.length; i++) { ps.format("%02X:", HAs[i]); } mac = baos.toString(); if (mac.length() > 0) { mac = mac.replaceFirst(":$", ""); } ps.close(); baos.close(); } return mac; }
From source file:com.zimbra.cs.service.authenticator.CertUtil.java
private void printIssuer(PrintStream outStream) { X500Principal issuerPrincipal = cert.getIssuerX500Principal(); outStream.format("Issuer: %s\n", issuerPrincipal.getName()); }
From source file:com.zimbra.cs.service.authenticator.CertUtil.java
private void printSubject(PrintStream outStream) { X500Principal subjectPrincipal = cert.getSubjectX500Principal(); outStream.format("Subject: %s\n", subjectPrincipal.getName()); }
From source file:com.analog.lyric.dimple.solvers.core.parameterizedMessages.DirichletParameters.java
@Override public void print(PrintStream out, int verbosity) { if (verbosity >= 0) { out.print("Dirichlet("); for (int i = 0, end = getSize(); i < end; ++i) { if (i > 0) { out.print(','); if (verbosity > 1) { out.print(' '); }/*from w w w . j av a 2s . c om*/ } if (verbosity > 1) { out.format("a%d=", i); } out.format("%g", getAlpha(i)); } out.print(')'); } }