本文整理汇总了Java中java.io.FileWriter.append方法的典型用法代码示例。如果您正苦于以下问题:Java FileWriter.append方法的具体用法?Java FileWriter.append怎么用?Java FileWriter.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.FileWriter
的用法示例。
在下文中一共展示了FileWriter.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create_config_file_pred
import java.io.FileWriter; //导入方法依赖的package包/类
/**
*
* @param filename : the configuration file name for required to run python from the command line
* @param datset : the dataset to be used
* @param model : model dump name
* @param predictionfile : where the predictions will be saved
* @param columns : Number of columns in the data
*/
private void create_config_file_pred(String filename , String datset, String model, String predictionfile, int columns){
try{ // Catch errors in I/O if necessary.
// Open a file to write to.
String saveFile = filename;
FileWriter writer = new FileWriter(saveFile);
writer.append("task=predict\n");
writer.append("columns=" + columns+ "\n");
writer.append("model=" +model+ "\n");
writer.append("data=" +datset+ "\n");
writer.append("prediction=" +predictionfile+ "\n");
if (this.verbose){
writer.append("verbose=1" + "\n");
}else {
writer.append("verbose=0" + "\n");
}
writer.close();
} catch (Exception e) {
throw new IllegalStateException(" failed to write the config file at: " + filename);
}
}
示例2: logDebugInfo
import java.io.FileWriter; //导入方法依赖的package包/类
private static void logDebugInfo(File debugLogFile, String msg, @Nullable Throwable t) {
Log.d(LOG_TAG, msg);
try {
FileWriter debugLogFileWriter = new FileWriter(debugLogFile, true);
msg = Utils.getFormattedDateTime(System.currentTimeMillis(), true) + " -> " + msg;
debugLogFileWriter.append("\n").append(msg).append("\n");
if (t != null) {
debugLogFileWriter.append(Utils.getStackTrace(t));
}
debugLogFileWriter.flush();
debugLogFileWriter.close();
}
catch (IOException ignored) {
}
}
示例3: createGOPFile
import java.io.FileWriter; //导入方法依赖的package包/类
private void createGOPFile(String fileName) throws IOException {
File gpsTrackDetailGOPFile = FileUtils.createGpsTrackDetailFile(GOP_FORMAT, fileName);
gpsTrackDetailGOPFileWriter = new FileWriter(gpsTrackDetailGOPFile);
//create the header
gpsTrackDetailGOPFileWriter.append("LatitudeE6,LongitudeE6,PointType\n");
ContentValues cvData = new ContentValues();
cvData.put(DBAdapter.COL_NAME_GPSTRACKDETAIL__GPSTRACK_ID, gpsTrackId);
cvData.put(DBAdapter.COL_NAME_GPSTRACKDETAIL__FILEFORMAT, GOP_FORMAT);
cvData.put(DBAdapter.COL_NAME_GPSTRACKDETAIL__FILE, gpsTrackDetailGOPFile.getAbsolutePath());
mDbAdapter.createRecord(DBAdapter.TABLE_NAME_GPSTRACKDETAIL, cvData);
gpsTrackDetailGOPFileWriter.flush();
if (isEnableDebugLog) {
logDebugInfo(debugLogFile, "createGOPFile: File created. gpsTrackDetailGOPFile = " + fileName, null);
}
}
示例4: create_config_file_pred
import java.io.FileWriter; //导入方法依赖的package包/类
/**
*
* @param filename : the configuration file name for required to run python from the command line
* @param datset : the dataset to be used
* @param model : model dump name
* @param predictionfile : where the predictions will be saved
* @param columns : Number of columns in the data
*/
private void create_config_file_pred(String filename , String datset, String model, String predictionfile, int columns){
try{ // Catch errors in I/O if necessary.
// Open a file to write to.
String saveFile = filename;
FileWriter writer = new FileWriter(saveFile);
writer.append("task=predict\n");
writer.append("columns=" + columns+ "\n");
writer.append("usedense=" + this.use_dense+ "\n");
writer.append("model=" +model+ "\n");
writer.append("data=" +datset+ "\n");
writer.append("prediction=" +predictionfile+ "\n");
writer.close();
} catch (Exception e) {
throw new IllegalStateException(" failed to write the config file at: " + filename);
}
}
示例5: runMT
import java.io.FileWriter; //导入方法依赖的package包/类
public void runMT() {
ClientManager manager = new ClientManager(parameterPool, this);
manager.createClients();
manager.startWarmup();
manager.startRun();
logger.info(printResults(true));
try {
FileWriter resultWriter = new FileWriter(xmlResultFile);
resultWriter.append(printXMLResults(true));
resultWriter.flush();
resultWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例6: create_config_file_pred
import java.io.FileWriter; //导入方法依赖的package包/类
/**
*
* @param filename : the configuration file name for required to run python from the command line
* @param datset : the dataset to be used
* @param model : model dump name
* @param predictionfile : where the predictions will be saved
* @param columns : Number of columns in the data
*/
private void create_config_file_pred(String filename , String datset, String model, String predictionfile, int columns){
try{ // Catch errors in I/O if necessary.
// Open a file to write to.
String saveFile = filename;
FileWriter writer = new FileWriter(saveFile);
writer.append("task=predict\n");
writer.append("columns=" + columns+ "\n");
writer.append("usedense=" + this.use_dense+ "\n");
writer.append("use_scale=" + this.use_scale+ "\n");
writer.append("model=" +model+ "\n");
writer.append("data=" +datset+ "\n");
writer.append("prediction=" +predictionfile+ "\n");
if (this.verbose){
writer.append("verbose=1" + "\n");
}else {
writer.append("verbose=0" + "\n");
}
writer.close();
} catch (Exception e) {
throw new IllegalStateException(" failed to write the config file at: " + filename);
}
}
示例7: addToReport
import java.io.FileWriter; //导入方法依赖的package包/类
public void addToReport(MSSQLTestData td, Object result) {
try {
FileWriter fr = new FileWriter(getOutputFileName(), true);
String offset = td.getData(KEY_STRINGS.OFFSET);
String dt = td.getDatatype();
String res = "_";
if (result == null) {
res = "Success";
} else {
try {
res = "FAILED "
+ removeNewLines(((AssertionError) result)
.getMessage());
} catch (Exception ae) {
if (result instanceof Exception) {
res = "FAILED "
+ removeNewLines(((Exception) result)
.getMessage());
} else {
res = "FAILED " + result.toString();
}
}
}
fr.append(offset + "\t" + "\t" + res + "\t" + dt + "\t"
+ removeNewLines(td.toString()) + "\n");
fr.close();
} catch (Exception e) {
LOG.error(StringUtils.stringifyException(e));
}
}
示例8: assertContents
import java.io.FileWriter; //导入方法依赖的package包/类
protected void assertContents(CharSequence sb) throws IOException {
File out = new File(getWorkDir(), fname + ".parsed");
FileWriter wr = new FileWriter(out);
wr.append(sb);
wr.close();
assertFile(out, getGoldenFile(fname + ".pass"), new File(getWorkDir(), fname + ".diff"));
}
示例9: create_config_file_pred
import java.io.FileWriter; //导入方法依赖的package包/类
/**
*
* @param filename : the conifiguration file name for required to run xgboost from the command line
* @param datset : the dataset to be used
* @param model : model dump name
* @param predictionfile : where the predictions will eb saved
*/
private void create_config_file_pred(String filename , String datset, String model, String predictionfile){
try{ // Catch errors in I/O if necessary.
// Open a file to write to.
String saveFile = filename;
FileWriter writer = new FileWriter(saveFile);
writer.append("objective=" + this.Objective+ "\n");
writer.append("is_sparse=true" + "\n");
writer.append("num_threads=" + this.threads + "\n");
if (this.verbose){
writer.append("verbosity=1" + "\n");
}else {
writer.append("verbosity=0" + "\n");
}
//file details
writer.append(datset+ "\n");
writer.append( model+ "\n");
writer.append( "output_result=" + predictionfile + "\n");
writer.close();
} catch (Exception e) {
throw new IllegalStateException(" failed to write the config file at: " + filename);
}
}
示例10: create_config_file_pred
import java.io.FileWriter; //导入方法依赖的package包/类
/**
*
* @param filename : the conifiguration file name for required to run xgboost from the command line
* @param datset : the dataset to be used
* @param model : model dump name
* @param predictionfile : where the predictions will eb saved
*/
private void create_config_file_pred(String filename , String datset, String model, String predictionfile){
try{ // Catch errors in I/O if necessary.
// Open a file to write to.
String saveFile = filename;
FileWriter writer = new FileWriter(saveFile);
writer.append("objective=" + this.Objective+ "\n");
writer.append("nthread=" + this.threads + "\n");
writer.append("max_leaves=" + this.max_leaves + "\n");
writer.append("save_period=0" + "\n");
if (this.verbose){
writer.append("silent=0" + "\n");
}else {
writer.append("silent=1" + "\n");
}
//file details
writer.append(datset+ "\n");
writer.append( model+ "\n");
writer.append( "name_pred=" + predictionfile + "\n");
writer.close();
} catch (Exception e) {
throw new IllegalStateException(" failed to write the config file at: " + filename);
}
}
示例11: writeIterationReport
import java.io.FileWriter; //导入方法依赖的package包/类
private void writeIterationReport(FileWriter writer, IterationReport report) {
try {
writer.append("Iteration " + report.getIteration() + ":" + LINE_SEPARATOR);
writer.append(INDENT + "Start Time: " + report.getStart().format(DateTimeFormatter.ISO_DATE_TIME) + LINE_SEPARATOR);
writer.append(INDENT + "End Time: " + report.getEnd().format(DateTimeFormatter.ISO_DATE_TIME) + LINE_SEPARATOR);
writer.append(INDENT + "Duration: " + report.getDuration().toMillis() + "ms" + LINE_SEPARATOR + LINE_SEPARATOR);
}catch (IOException e){
throw new WrappedIOException(e);
}
}
示例12: writeToFile
import java.io.FileWriter; //导入方法依赖的package包/类
public void writeToFile(int startCount, int endCount, String fileName) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("MTableDataCommandResult.writeToFile startCount = " + startCount + " endCount = "
+ endCount + " fileName = " + fileName);
}
boolean isFTable = this.isFTable;
FileWriter writer = new FileWriter(fileName, true);
for (int i = startCount; i <= endCount; i++) {
if (i >= this.resultValues.size()) {
break;
}
Row row = resultValues.get(i);
if (i == 0) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("#"); // This is for header (comment in csv).
if (!isFTable) {
stringBuilder.append("RowID");
}
List<Cell> cells = row.getCells();
for (int j = 0; j < cells.size(); j++) {
if (isFTable) {
if (j > 0) {
stringBuilder.append(",");
}
} else {
stringBuilder.append(",");
}
stringBuilder.append(Bytes.toString(cells.get(j).getColumnName()));
stringBuilder.append(":");
stringBuilder.append(cells.get(j).getColumnType().toString());
}
writer.append(stringBuilder.toString());
writer.append('\n');
writer.flush();
}
toMResultCSV(row, writer, isFTable);
}
writer.close();
}
示例13: create_config_file_pred
import java.io.FileWriter; //导入方法依赖的package包/类
/**
*
* @param filename : the configuration file name for required to run python from the command line
* @param datset : the dataset to be used
* @param model : model dump name
* @param predictionfile : where the predictions will be saved
* @param columns : Number of columns in the data
*/
private void create_config_file_pred(String filename , String datset, String model, String predictionfile, int columns){
try{ // Catch errors in I/O if necessary.
// Open a file to write to.
String saveFile = filename;
FileWriter writer = new FileWriter(saveFile);
writer.append("task=predict\n");
writer.append("columns=" + columns+ "\n");
writer.append("usedense=" + this.use_dense+ "\n");
writer.append("model=" +model+ "\n");
writer.append("data=" +datset+ "\n");
writer.append("prediction=" +predictionfile+ "\n");
if (this.verbose){
writer.append("verbose=1" + "\n");
}else {
writer.append("verbose=0" + "\n");
}
writer.close();
} catch (Exception e) {
throw new IllegalStateException(" failed to write the config file at: " + filename);
}
}
示例14: addToReport
import java.io.FileWriter; //导入方法依赖的package包/类
public synchronized void addToReport(MSSQLTestData td, Object result) {
System.out.println("called");
try {
FileWriter fr = new FileWriter(getResportFileName(), true);
String offset = td.getData(KEY_STRINGS.OFFSET);
String res = "_";
if (result == null) {
res = "Success";
} else {
try {
res = "FAILED "
+ removeNewLines(((AssertionError) result)
.getMessage());
} catch (Exception ae) {
if (result instanceof Exception
&& ((Exception) result) != null) {
res = "FAILED "
+ removeNewLines(((Exception) result)
.getMessage());
} else {
res = "FAILED " + result.toString();
}
}
}
fr.append(offset + "\t" + res + "\n");
fr.close();
} catch (Exception e) {
LOG.error(StringUtils.stringifyException(e));
}
}
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:32,代码来源:SQLServerDatatypeImportSequenceFileManualTest.java
示例15: create_config_file
import java.io.FileWriter; //导入方法依赖的package包/类
/**
*
* @param filename : the conifiguration file name for required to run xgboost from the command line
* @param datset : the dataset to be used
* @param model : model dump name
* @param columns : Number of columns in the data
*/
private void create_config_file(String filename , String datset, String model, int columns){
try{ // Catch errors in I/O if necessary.
// Open a file to write to.
String saveFile = filename;
FileWriter writer = new FileWriter(saveFile);
writer.append("task=train\n");
writer.append("columns=" + columns+ "\n");
writer.append("usedense=" + this.use_dense+ "\n");
writer.append("model=" +model+ "\n");
writer.append("data=" +datset+ "\n");
writer.append("criterion=" + this.criterion + "\n");
writer.append("max_depth=" +this.max_depth + "\n");
writer.append("max_features=" + this.max_features + "\n");
writer.append("max_leaf_nodes=" + this.max_leaf_nodes+ "\n");
writer.append("min_impurity_split=" + this.min_impurity_split + "\n");
writer.append("min_samples_leaf=" + this.min_samples_leaf + "\n");
writer.append("min_samples_split=" + this.min_samples_split + "\n");
writer.append("min_weight_fraction_leaf=" + this.min_weight_fraction_leaf + "\n");
writer.append("max_depth=" + this.max_depth + "\n");
writer.append("random_state=" + this.seed + "\n");
writer.close();
} catch (Exception e) {
throw new IllegalStateException(" failed to write the config file at: " + filename);
}
}