本文整理汇总了Java中java.util.Formatter.close方法的典型用法代码示例。如果您正苦于以下问题:Java Formatter.close方法的具体用法?Java Formatter.close怎么用?Java Formatter.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Formatter
的用法示例。
在下文中一共展示了Formatter.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import java.util.Formatter; //导入方法依赖的package包/类
public static String toString(BarcodeValue[][] barcodeMatrix) {
Formatter formatter = new Formatter();
for (int row = 0; row < barcodeMatrix.length; row++) {
formatter.format("Row %2d: ", new Object[]{Integer.valueOf(row)});
for (BarcodeValue barcodeValue : barcodeMatrix[row]) {
if (barcodeValue.getValue().length == 0) {
formatter.format(" ", (Object[]) null);
} else {
formatter.format("%4d(%2d)", new Object[]{Integer.valueOf
(barcodeMatrix[row][column].getValue()[0]),
barcodeMatrix[row][column].getConfidence(barcodeMatrix[row][column]
.getValue()[0])});
}
}
formatter.format("%n", new Object[0]);
}
String result = formatter.toString();
formatter.close();
return result;
}
示例2: toFormattedString
import java.util.Formatter; //导入方法依赖的package包/类
/***
* Returns a string representation of the FTPFile information.
* This currently mimics the Unix listing format.
*
* @return A string representation of the FTPFile information.
* @since 3.0
*/
public String toFormattedString()
{
StringBuilder sb = new StringBuilder();
Formatter fmt = new Formatter(sb);
sb.append(formatType());
sb.append(permissionToString(USER_ACCESS));
sb.append(permissionToString(GROUP_ACCESS));
sb.append(permissionToString(WORLD_ACCESS));
fmt.format(" %4d", Integer.valueOf(getHardLinkCount()));
fmt.format(" %-8s %-8s", getGroup(), getUser());
fmt.format(" %8d", Long.valueOf(getSize()));
Calendar timestamp = getTimestamp();
if (timestamp != null) {
fmt.format(" %1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS", timestamp);
fmt.format(" %1$tZ", timestamp);
sb.append(' ');
}
sb.append(' ');
sb.append(getName());
fmt.close();
return sb.toString();
}
示例3: buildSensorControlCommand
import java.util.Formatter; //导入方法依赖的package包/类
/**
* build TDV string of the sensor control command
* @param info sensor info
* @param value command value
* @return TDV command string
*/
public static String buildSensorControlCommand(SensorInfo info, int value) {
Formatter formatter = new Formatter();
formatter.format("%02x", info.getType().getValueTDVTypes()[0]);
switch (info.getType()) {
case BUZZER:
formatter.format("%02x", ValueType.UCHAR.getCode());
formatter.format("%02x", value);
break;
case LED:
formatter.format("%02x", ValueType.CHAR3.getCode());
formatter.format("%06x", value);
break;
default:
formatter.format("%02x", ValueType.BOOL.getCode());
formatter.format("%02x", value);
break;
}
String result = formatter.toString();
formatter.close();
return result;
}
示例4: listArray
import java.util.Formatter; //导入方法依赖的package包/类
/**
* Generates a string holding the named definition
* of a 2D double array for Mathematica in the form
* name = {{A[0][0],...,A[0][m-1]},
* {A[1][0],...,A[1][m-1]}, ...,
* {A[n-1][0], A[n-1][1], ...,A[n-1][m-1]}};
* @param name the identifier to be used in Mathematica.
* @param A the array to be encoded (of length m).
* @return a String holding the Mathematica definition.
*/
public static String listArray(String name, double[][] A) {
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb, Locale.US);
String fs = PrintPrecision.getFormatStringFloat();
formatter.format(name + " = {");
for (int i = 0; i < A.length; i++) {
if (i == 0)
formatter.format("{");
else
formatter.format(", \n{");
for (int j = 0; j < A[i].length; j++) {
if (j == 0)
formatter.format(fs, A[i][j]);
else
formatter.format(", " + fs, A[i][j]);
}
formatter.format("}");
}
formatter.format("};\n");
String result = formatter.toString();
formatter.close();
return result;
}
示例5: toString
import java.util.Formatter; //导入方法依赖的package包/类
public static String toString(BarcodeValue[][] barcodeMatrix) {
Formatter formatter = new Formatter();
for (int row = 0; row < barcodeMatrix.length; row++) {
formatter.format("Row %2d: ", row);
for (int column = 0; column < barcodeMatrix[row].length; column++) {
BarcodeValue barcodeValue = barcodeMatrix[row][column];
if (barcodeValue.getValue().length == 0) {
formatter.format(" ", (Object[]) null);
} else {
formatter.format("%4d(%2d)", barcodeValue.getValue()[0],
barcodeValue.getConfidence(barcodeValue.getValue()[0]));
}
}
formatter.format("%n");
}
String result = formatter.toString();
formatter.close();
return result;
}
示例6: stringForTimeNoHour
import java.util.Formatter; //导入方法依赖的package包/类
public static String stringForTimeNoHour(long timeMs) {
String formatter;
StringBuilder formatBuilder = new StringBuilder();
Formatter formatter2 = new Formatter(formatBuilder, Locale.getDefault());
if (timeMs >= 0) {
try {
int totalSeconds = (int) (timeMs / 1000);
int seconds = totalSeconds % 60;
int minutes = totalSeconds / 60;
formatBuilder.setLength(0);
formatter = formatter2.format("%02d:%02d", new Object[]{Integer.valueOf(minutes), Integer.valueOf(seconds)}).toString();
} finally {
formatter2.close();
}
} else {
formatter = "00:00";
formatter2.close();
}
return formatter;
}
示例7: stringForTime
import java.util.Formatter; //导入方法依赖的package包/类
public static String stringForTime(long timeMs) {
StringBuilder formatBuilder = new StringBuilder();
Formatter formatter = new Formatter(formatBuilder, Locale.getDefault());
try {
String formatter2;
int totalSeconds = (int) (timeMs / 1000);
int seconds = totalSeconds % 60;
int minutes = (totalSeconds / 60) % 60;
int hours = totalSeconds / 3600;
formatBuilder.setLength(0);
if (hours > 0) {
formatter2 = formatter.format("%02d:%02d:%02d", new Object[]{Integer.valueOf(hours), Integer.valueOf(minutes), Integer.valueOf(seconds)}).toString();
} else {
formatter2 = formatter.format("%02d:%02d", new Object[]{Integer.valueOf(minutes), Integer.valueOf(seconds)}).toString();
formatter.close();
}
return formatter2;
} finally {
formatter.close();
}
}
示例8: getNumberTime2
import java.util.Formatter; //导入方法依赖的package包/类
public static String getNumberTime2(long time_second) {
Formatter formatter = new Formatter(null, Locale.getDefault());
if (time_second < 0) {
time_second = 0;
}
try {
String formatter2;
long seconds = time_second % 60;
if (time_second / 60 > 99) {
formatter2 = formatter.format("%03d:%02d", new Object[]{Long.valueOf(time_second / 60), Long.valueOf(seconds)}).toString();
} else {
formatter2 = formatter.format("%02d:%02d", new Object[]{Long.valueOf(time_second / 60), Long.valueOf(seconds)}).toString();
formatter.close();
}
return formatter2;
} finally {
formatter.close();
}
}
示例9: toString
import java.util.Formatter; //导入方法依赖的package包/类
public String toString() {
Formatter fm = new Formatter(new StringBuilder(), Locale.US);
fm.format("Region %d", label);
fm.format(", area = %d", size);
fm.format(", bounding box = (%d, %d, %d, %d)", left, top, right, bottom );
fm.format(", centroid = (%.2f, %.2f)", xc, yc);
if (innerContours != null)
fm.format(", holes = %d", innerContours.size());
String s = fm.toString();
fm.close();
return s;
}
示例10: byteToHex
import java.util.Formatter; //导入方法依赖的package包/类
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;
}
示例11: byteArray2Hex
import java.util.Formatter; //导入方法依赖的package包/类
private static String byteArray2Hex(final byte[] hash) {
Formatter formatter = new Formatter();
try {
for (byte b : hash) {
formatter.format("%02x", b);
}
return formatter.toString();
} finally {
formatter.close();
}
}
示例12: toString
import java.util.Formatter; //导入方法依赖的package包/类
public String toString() {
Formatter formatter = new Formatter();
Codeword[] codewordArr = this.codewords;
int length = codewordArr.length;
int i = 0;
int row = 0;
while (i < length) {
int row2;
Codeword codeword = codewordArr[i];
Object[] objArr;
if (codeword == null) {
objArr = new Object[1];
row2 = row + 1;
objArr[0] = Integer.valueOf(row);
formatter.format("%3d: | %n", objArr);
} else {
objArr = new Object[3];
row2 = row + 1;
objArr[0] = Integer.valueOf(row);
objArr[1] = Integer.valueOf(codeword.getRowNumber());
objArr[2] = Integer.valueOf(codeword.getValue());
formatter.format("%3d: %3d|%3d%n", objArr);
}
i++;
row = row2;
}
String result = formatter.toString();
formatter.close();
return result;
}
示例13: print
import java.util.Formatter; //导入方法依赖的package包/类
void print(float[] arr) {
int linelength = 16;
StringBuilder sb = new StringBuilder();
Formatter fm = new Formatter(sb, Locale.US);
for (int i = 0; i < arr.length; i++) {
if (i > 0 && i % linelength == 0) {
IJ.log(sb.toString());
sb.setLength(0);
}
fm.format(" %.2f", arr[i]);
}
IJ.log(sb.toString());
fm.close();
}
示例14: doStepInternal
import java.util.Formatter; //导入方法依赖的package包/类
protected void doStepInternal() {
try {
Formatter formatter = new Formatter("energy-"+fileTail);
Vector pos = adatom.getPosition();
// Move atom along Y-axis, steps by 0.1
for(int i=0; i<292; i++){ //292
// Return atom to original Z position
adatom.getPosition().setX(2, -1.6);
// Move atom along Z-axis, steps by 0.1
for(int j=0; j<213; j++){ //213
// --PRINT--
formatter.format("%f %7.2f %7.2f %7.2f \n",new Object[] {energy.getDataAsScalar(),pos.getX(0), pos.getX(1), pos.getX(2)});
// Step atom by 0.1 along Z-axis
adatom.getPosition().setX(2, adatom.getPosition().getX(2) +0.02);
}
// Step atom by 0.1 along Y-axis
adatom.getPosition().setX(1, adatom.getPosition().getX(1) + 0.02);
}
formatter.close();
}
catch (IOException e) {
}
}
示例15: buildSensorControlCommand
import java.util.Formatter; //导入方法依赖的package包/类
/**
* build TLV string of the sensor control command
* @param info sensor info
* @param value command value
* @return TLV command string
*/
public static String buildSensorControlCommand(SensorInfo info, int value) {
Formatter formatter = new Formatter();
formatter.format("%02x", info.getType().getValueTLVTypes()[0]);
formatter.format("%02x", 1);
formatter.format("%02x", value);
String result = formatter.toString();
formatter.close();
return result;
}