//【1】创建输出流文件对象
FileOutputStream fos = new FileOutputStream("/Users/student/Desktop/DTW_Java.txt",true);
//【2】写出文件
for(int i=0;i<resultDemo.size();i++){
if(i%22==0){
String str="\r\n";
byte [] by = str.getBytes(); //把String类型转为byte数组
fos.write(by, 0, by.length);
}
for(int ii=0;ii < 3;ii++){
String str0 = String.valueOf(resultDemo.get(i).get(ii).doubleValue());
String str=str0+"\t";
byte [] by = str.getBytes(); //把String类型转为byte数组
fos.write(by, 0, by.length);
}
}
//【3】关流
fos.close();
System.out.println("写入完毕");
java 写出到文件
最新推荐文章于 2024-08-20 17:23:57 发布