List of usage examples for java.util Formatter Formatter
public Formatter()
From source file:fr.gael.dhus.util.http.DownloadableProduct.java
/** raise an IOException with the given StatusLine and cause Header (cause may be null). */ private void raiseFailure(StatusLine stl, Header cause) throws IOException { Formatter ff = new Formatter(); ff.format("Cannot download %s, Reason='%s' (HTTP%d)", this.url, stl.getReasonPhrase(), stl.getStatusCode()); if (cause != null) { String cause_msg = cause.getValue(); if (cause_msg != null && !cause_msg.isEmpty()) { ff.format(" Cause='%s'", cause_msg); }/*from w w w .j a va 2 s.co m*/ } throw new IOException(ff.out().toString()); }
From source file:edu.cmu.tetrad.cli.search.FgsCli.java
private static String createOutputRunInfo(Set<String> excludedVariables, DataSet dataSet) { Formatter fmt = new Formatter(); fmt.format("Runtime Parameters:%n"); fmt.format("verbose = %s%n", verbose); fmt.format("number of threads = %s%n", numOfThreads); fmt.format("%n"); fmt.format("Dataset:%n"); fmt.format("file = %s%n", dataFile.getFileName()); fmt.format("delimiter = %s%n", Args.getDelimiterName(delimiter)); fmt.format("cases read in = %s%n", dataSet.getNumColumns()); fmt.format("variables read in = %s%n", dataSet.getNumRows()); fmt.format("%n"); if (excludedVariableFile != null || knowledgeFile != null) { fmt.format("Filters:%n"); if (excludedVariableFile != null) { fmt.format("excluded variables (%d variables) = %s%n", excludedVariables.size(), excludedVariableFile.getFileName()); }/*from ww w . j av a 2s. c om*/ if (knowledgeFile != null) { fmt.format("knowledge = %s%n", knowledgeFile.getFileName()); } fmt.format("%n"); } fmt.format("FGS Parameters:%n"); fmt.format("penalty discount = %f%n", penaltyDiscount); fmt.format("depth = %d%n", depth); fmt.format("%n"); fmt.format("Run Options:%n"); fmt.format("heuristic speedup = %s%n", heuristicSpeedup); fmt.format("ignore linear dependence = %s%n", ignoreLinearDependence); fmt.format("%n"); fmt.format("Data Validations:%n"); fmt.format("skip unique variable name check = %s%n", skipUniqueVarName); fmt.format("skip variables with zero variance check = %s%n", skipZeroVariance); fmt.format("%n"); return fmt.toString(); }
From source file:edu.cmu.tetrad.cli.AbstractAlgorithmCli.java
private String createArgsInfo() { Formatter fmt = new Formatter(); if (dataFile != null) { fmt.format("data = %s%n", dataFile.getFileName()); }/*w ww .j a v a 2s .c o m*/ if (excludedVariableFile != null) { fmt.format("exclude-variables = %s%n", excludedVariableFile.getFileName()); } if (knowledgeFile != null) { fmt.format("knowledge = %s%n", knowledgeFile.getFileName()); } fmt.format("delimiter = %s%n", Args.getDelimiterName(delimiter)); fmt.format("verbose = %s%n", verbose); fmt.format("thread = %s%n", numOfThreads); printParameterInfos(fmt); printValidationInfos(fmt); fmt.format("out = %s%n", dirOut.getFileName().toString()); fmt.format("output-prefix = %s%n", outputPrefix); fmt.format("no-validation-output = %s%n", !validationOutput); return fmt.toString(); }
From source file:no.trank.openpipe.solr.SolrHttpDocumentPoster.java
private String createFileName() { return new Formatter().format("%1$04d.xml", postCount++).toString(); }
From source file:org.apache.camel.component.mongodb.MongoDbOperationsTest.java
@Test public void testColStats() throws Exception { assertEquals(0, testCollection.count()); // Add some records to the collection (and do it via camel-mongodb) for (int i = 1; i <= 100; i++) { String body = null;//from w w w .j a v a 2s . c o m Formatter f = new Formatter(); body = f.format("{\"_id\":\"testSave%d\", \"scientist\":\"Einstein\"}", i).toString(); template.requestBody("direct:insert", body); } Object result = template.requestBody("direct:getColStats", "irrelevantBody"); assertTrue("Result is not of type DBObject", result instanceof DBObject); assertTrue("The result should contain keys", ((DBObject) result).keySet().size() > 0); }
From source file:edu.cmu.tetrad.cli.AbstractAlgorithmCli.java
private String creteHeading(AlgorithmType algorithmType) { Formatter fmt = new Formatter(); fmt.format("================================================================================%n"); fmt.format("%s (%s)%n", algorithmType.getTitle(), AppTool.fmtDateNow()); fmt.format("================================================================================%n"); return fmt.toString(); }
From source file:com.lightbox.android.bitmap.BitmapUtils.java
private static String md5ToString(byte[] md5Hash) { Formatter formatter = new Formatter(); for (byte b : md5Hash) { formatter.format("%02x", b); }/*from ww w.j av a 2s. co m*/ return formatter.toString(); }
From source file:edu.cmu.tetrad.cli.search.FgsDiscrete.java
private static String createOutputRunInfo(Set<String> excludedVariables, DataSet dataSet) { Formatter fmt = new Formatter(); fmt.format("Runtime Parameters:%n"); fmt.format("verbose = %s%n", verbose); fmt.format("number of threads = %s%n", numOfThreads); fmt.format("%n"); fmt.format("Dataset:%n"); fmt.format("file = %s%n", dataFile.getFileName()); fmt.format("delimiter = %s%n", Args.getDelimiterName(delimiter)); fmt.format("cases read in = %s%n", dataSet.getNumColumns()); fmt.format("variables read in = %s%n", dataSet.getNumRows()); fmt.format("%n"); if (excludedVariableFile != null || knowledgeFile != null) { fmt.format("Filters:%n"); if (excludedVariableFile != null) { fmt.format("excluded variables (%d variables) = %s%n", excludedVariables.size(), excludedVariableFile.getFileName()); }/* ww w . j a va 2 s . c o m*/ if (knowledgeFile != null) { fmt.format("knowledge = %s%n", knowledgeFile.getFileName()); } fmt.format("%n"); } fmt.format("FGS Discrete Parameters:%n"); fmt.format("structure prior = %f%n", structurePrior); fmt.format("sample prior = %f%n", samplePrior); fmt.format("depth = %d%n", depth); fmt.format("%n"); fmt.format("Run Options:%n"); fmt.format("heuristic speedup = %s%n", heuristicSpeedup); fmt.format("%n"); fmt.format("Data Validations:%n"); fmt.format("skip unique variable name check = %s%n", skipUniqueVarName); fmt.format("skip limit number of category check = %s%n", skipCategoryLimit); fmt.format("%n"); return fmt.toString(); }
From source file:Networking.Server.java
private static String toHexString(byte[] bytes) { Formatter formatter = new Formatter(); for (byte b : bytes) { formatter.format("%02x", b); }/*ww w . j a va 2 s. c o m*/ return formatter.toString(); }
From source file:com.github.jengelman.gradle.plugins.integration.TestFile.java
public TestFile writelns(Iterable<String> lines) { Formatter formatter = new Formatter(); for (String line : lines) { formatter.format("%s%n", line); }//www . j av a 2s. c om return write(formatter); }