本文整理了Java中java.util.Formatter.close()
方法的一些代码示例,展示了Formatter.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Formatter.close()
方法的具体详情如下:
包路径:java.util.Formatter
类名称:Formatter
方法名:close
[英]Closes the Formatter. If the output destination is Closeable, then the method close() will be called on that destination. If the Formatter has been closed, then calling the this method will have no effect. Any method but the #ioException() that is called after the Formatter has been closed will raise a FormatterClosedException.
[中]关闭格式化程序。如果输出目标是可关闭的,那么将在该目标上调用close()方法。如果格式化程序已关闭,则调用this方法将无效。关闭格式化程序后调用的#ioException()以外的任何方法都会引发FormatterClosedException。
代码示例来源:origin: knowm/XChange
private static String byteToHex(final byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash) {
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
}
代码示例来源:origin: apache/hive
Formatter fmt = new Formatter(sb);
if (doCSV) {
result.displayCSV(fmt, csvSeparator);
Formatter f = new Formatter(s);
result.display(f);
System.out.print(s);
f.close();
fmt.close();
代码示例来源:origin: org.assertj/assertj-core
private static String escapeUnicode(String input) {
StringBuilder b = new StringBuilder(input.length());
Formatter formatter = new Formatter(b);
for (char c : input.toCharArray()) {
if (c < 128) {
b.append(c);
} else {
formatter.format("\\u%04x", (int) c);
}
}
formatter.close();
return b.toString();
}
}
代码示例来源:origin: stackoverflow.com
Formatter output = new Formatter("file.txt");
try {
// your code
} finally {
output.close();
}
代码示例来源:origin: joel-costigliola/assertj-core
private static String escapeUnicode(String input) {
StringBuilder b = new StringBuilder(input.length());
Formatter formatter = new Formatter(b);
for (char c : input.toCharArray()) {
if (c < 128) {
b.append(c);
} else {
formatter.format("\\u%04x", (int) c);
}
}
formatter.close();
return b.toString();
}
}
代码示例来源:origin: stackoverflow.com
FileWriter fstream = new FileWriter("data.txt",true);
Formatter w = new Formatter(fstream);
// do whatever your program needs to do
w.close();
代码示例来源:origin: org.apache.poi/poi
private void writeSingleInteger(String fmt, int num, StringBuffer output, List<Special> numSpecials, Set<CellNumberStringMod> mods) {
StringBuffer sb = new StringBuffer();
Formatter formatter = new Formatter(sb, locale);
try {
formatter.format(locale, fmt, num);
} finally {
formatter.close();
}
writeInteger(sb, output, numSpecials, mods, false);
}
代码示例来源:origin: biz.aQute.bnd/bnd
private void printHelp() throws Exception {
Formatter f = new Formatter();
opts._command().help(f, this);
bnd.out.println(f);
f.close();
}
代码示例来源:origin: org.apache.poi/poi
/** {@inheritDoc} */
public void formatValue(StringBuffer toAppendTo, Object value) {
double elapsed = ((Number) value).doubleValue();
if (elapsed < 0) {
toAppendTo.append('-');
elapsed = -elapsed;
}
Object[] parts = new Long[specs.size()];
for (int i = 0; i < specs.size(); i++) {
parts[i] = specs.get(i).valueFor(elapsed);
}
Formatter formatter = new Formatter(toAppendTo, Locale.ROOT);
try {
formatter.format(printfFmt, parts);
} finally {
formatter.close();
}
}
代码示例来源:origin: com.linkedin.pegasus/data
@Override
public String toString()
{
String fieldSeparator = getFieldSeparator();
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb);
format(formatter, fieldSeparator);
formatter.flush();
formatter.close();
return sb.toString();
}
}
代码示例来源:origin: stackoverflow.com
Formatter formatter = new Formatter();
for (byte b : hash)
formatter.format("%02x", b);
formatter.close();
return result;
代码示例来源:origin: org.apache.poi/poi
Formatter formatter = new Formatter(toAppendTo, locale);
try {
formatter.format(locale, fmt, value);
} finally {
formatter.close();
代码示例来源:origin: com.google.inject/guice
Formatter fmt = new Formatter(sb);
fmt.format("Encountered circular dependency spanning several threads.");
if (proxyCreationError != null) {
fmt.format(" %s", proxyCreationError.getMessage());
fmt.format("%n");
for (Thread lockedThread : locksCycle.keySet()) {
List<Key<?>> lockedKeys = locksCycle.get(lockedThread);
fmt.close();
return new Message(Thread.currentThread(), sb.toString());
代码示例来源:origin: opentripplanner/OpenTripPlanner
private List<URL> getDownloadURLsCached() {
Envelope extent = graph.getExtent();
Formatter formatter = new Formatter();
String filename = formatter.format("%f,%f-%f,%f.urls", extent.getMinX(), extent.getMinY(),
extent.getMaxX(), extent.getMaxY()).toString();
formatter.close();
try {
File file = new File(cacheDirectory, filename);
代码示例来源:origin: apache/hive
Formatter formatter = new Formatter(sb, Locale.US);
formatter.format(pattern.toString(), argumentList.toArray());
resultText.set(sb.toString());
formatter.close();
代码示例来源:origin: apache/drill
Formatter formatter = new Formatter(sb, Locale.US);
formatter.format(pattern.toString(), argumentList.toArray());
resultText.set(sb.toString());
formatter.close();
代码示例来源:origin: org.apache.poi/poi
} else {
StringBuffer result = new StringBuffer();
Formatter f = new Formatter(result, locale);
try {
f.format(locale, printfFmt, value);
} finally {
f.close();
代码示例来源:origin: apache/cloudstack
public static String byte2Mac(final byte[] m) {
final StringBuilder result = new StringBuilder(17);
final Formatter formatter = new Formatter(result);
formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", m[0], m[1], m[2], m[3], m[4], m[5]);
formatter.close();
return result.toString();
}
代码示例来源:origin: Vazkii/Botania
@Override
public String toString() {
StringBuilder stringbuilder = new StringBuilder();
Formatter formatter = new Formatter(stringbuilder, Locale.US);
formatter.format("Quaternion:%n");
formatter.format(" < %f %f %f %f >%n", s, x, y, z);
formatter.close();
return stringbuilder.toString();
}
代码示例来源:origin: tabulapdf/tabula-java
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb);
String rv = formatter.format("%s[x1=%f y1=%f x2=%f y2=%f]", this.getClass().toString(), this.x1, this.y1, this.x2, this.y2).toString();
formatter.close();
return rv;
}
内容来源于网络,如有侵权,请联系作者删除!