本文整理汇总了Java中java.util.Formatter.flush方法的典型用法代码示例。如果您正苦于以下问题:Java Formatter.flush方法的具体用法?Java Formatter.flush怎么用?Java Formatter.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Formatter
的用法示例。
在下文中一共展示了Formatter.flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: outputHeader
import java.util.Formatter; //导入方法依赖的package包/类
/**
* Outputs stats headers into the 'output'.
*
* @param output
*/
public void outputHeader(Formatter output) {
if (output == null) return;
synchronized(output) {
output.format("MatchTime;UT2004Time;Health;Armor;Adrenaline;Score;Deaths;Suicides;Killed;WasKilled;NumKillsWithoutDeath;"
// 1 1.1 2 3 4 5 6 7 8 9 10
+"Team;TeamScore;"
// 11 12
+"ItemsCollect;WeaponsCollect;AmmoCollect;HealthCollect;ArmorCollect;ShieldCollect;AdrenalineCollect;OtherCollect;"
// 13 14 15 16 17 18 19 20
+"TimeMoving;TimeShooting;DoubleDamageCount;DoubleDamageTime;TraveledDistance;"
// 21 22 23 24 25
+"Combo;HasDoubleDamage;IsShooting;Velocity;Location_x;Location_y;Location_z");
// 26 27 28 29 30 31 32
// WEAPON USED
for (ItemType weapon : ItemType.Category.WEAPON.getTypes()) {
output.format(";" + fixSemicolon(weapon.getName()).replace(".", "_") + "_TimeUsed");
}
// EVENTS
output.format(";Event;EventParams...\n");
output.flush();
}
}
示例2: run
import java.util.Formatter; //导入方法依赖的package包/类
public void run()
{
try // send message and flush formatter
{
Formatter output =
new Formatter( clientSocket.getOutputStream() );
output.format( "%s\n", messageToSend ); // send message
output.flush(); // flush output
} // end try
catch ( IOException ioException )
{
ioException.printStackTrace();
} // end catch
}
示例3: toString
import java.util.Formatter; //导入方法依赖的package包/类
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
Formatter f = new Formatter(sb, Locale.getDefault());
f.format("Classes:%n");
f.format("%s%n", classes);
f.format("FieldRefs:%n");
f.format("%s%n", fieldRefs);
f.format("MethodRefs:%n");
f.format("%s%n", methodRefs);
f.format("InterfaceMethodRefs:%n");
f.format("%s%n", intfMethodRefs);
f.flush();
return sb.toString();
}
示例4: saveModel
import java.util.Formatter; //导入方法依赖的package包/类
/**
* Writes the model to the modelOutput. It uses {@link java.util.Locale#ENGLISH} for number
* formatting.
*
* <p>
* <b>Note: The modelOutput is closed after reading or in case of an exception.</b>
* </p>
*/
public static void saveModel(Writer modelOutput, Model model) throws IOException {
int nr_feature = model.nr_feature;
int w_size = nr_feature;
if (model.bias >= 0) {
w_size++;
}
int nr_w = model.nr_class;
if (model.nr_class == 2 && model.solverType != SolverType.MCSVM_CS) {
nr_w = 1;
}
Formatter formatter = new Formatter(modelOutput, DEFAULT_LOCALE);
try {
printf(formatter, "solver_type %s\n", model.solverType.name());
printf(formatter, "nr_class %d\n", model.nr_class);
if (model.label != null) {
printf(formatter, "label");
for (int i = 0; i < model.nr_class; i++) {
printf(formatter, " %d", model.label[i]);
}
printf(formatter, "\n");
}
printf(formatter, "nr_feature %d\n", nr_feature);
printf(formatter, "bias %.16g\n", model.bias);
printf(formatter, "w\n");
for (int i = 0; i < w_size; i++) {
for (int j = 0; j < nr_w; j++) {
double value = model.w[i * nr_w + j];
/** this optimization is the reason for {@link Model#equals(double[], double[])} */
if (value == 0.0) {
printf(formatter, "%d ", 0);
} else {
printf(formatter, "%.16g ", value);
}
}
printf(formatter, "\n");
}
formatter.flush();
IOException ioException = formatter.ioException();
if (ioException != null) {
throw ioException;
}
} finally {
formatter.close();
}
}
示例5: outputStatLine
import java.util.Formatter; //导入方法依赖的package包/类
/**
* Outputs stats line into 'output' appending 'eventOutput' at the end (also separated by semicolons)
*
* @param output
* @param eventOutput
*/
public void outputStatLine(Formatter output, double time, String... eventOutput) {
if (output == null) return;
synchronized(output) {
output.format("%.3f;%.3f;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%.3f;%.3f;%d;%.3f;%.3f;%s;%d;%d;%.3f;%.3f;%.3f;%.3f",
// 1 1.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
time, // 1
getCurrentUT2004Time(), // 1.1
(self == null ? 0 : self.getHealth()), // 2
(self == null ? 0 : self.getArmor()), // 3
(self == null ? 0 : self.getAdrenaline()), // 4
getScore(), // 5
deaths, // 6
suicides, // 7
killedOthers, // 8
killedByOthers, // 9
numberOfPlayersKilledWithoutDeath, // 10
(self == null ? 255 : self.getTeam()), // 11
getTeamScore(), // 12
totalItemsCollected, // 13
itemsByCategoryCollected.get(ItemType.Category.WEAPON), // 14
itemsByCategoryCollected.get(ItemType.Category.AMMO), // 15
itemsByCategoryCollected.get(ItemType.Category.HEALTH), // 16
itemsByCategoryCollected.get(ItemType.Category.ARMOR), // 17
itemsByCategoryCollected.get(ItemType.Category.SHIELD), // 18
itemsByCategoryCollected.get(ItemType.Category.ADRENALINE), // 19
itemsByCategoryCollected.get(ItemType.Category.OTHER), // 20
timeMoving, // 21
timeShooting, // 22
doubleDamageCount, // 23
doubleDamageTime, // 24
travelledDistance, // 25
(self == null ? "" : fixSemicolon(self.getCombo())), // 26
(self == null ? 0 : self.getUDamageTime() > 0 ? 1 : 0), // 27
(self == null ? 0 : (self.isShooting() || self.isAltFiring()) ? 1 : 0), // 28
(self == null ? (double)0 : self.getVelocity().size()), // 29
(self == null ? (double)0 : self.getLocation().x), // 30
(self == null ? (double)0 : self.getLocation().y), // 31
(self == null ? (double)0 : self.getLocation().z) // 32
);
// WEAPON USED
for (ItemType weapon : ItemType.Category.WEAPON.getTypes()) {
output.format(";%.3f", weaponsUsedTime.get(weapon));
}
// EVENTS
for (String event : eventOutput) {
output.format(";%s", fixSemicolon(event));
}
output.format("\n");
output.flush();
}
}