Java文件读写:
##Java文件读写:
String path="/home/hadoop/spark/practice_data/out.dat";
FileOutputStream fileos=new FileOutputStream(path);
ObjectOutputStream objectos=new ObjectOutputStream(fileos);
objectos.flush();
fileos.close();//记得要关闭,不然不会写出结果来
objectos.close();
Java文件读写-读一行中文:
//读取一行中文
public static void readLine(String path) throws IOException {
FileInputStream fis=new FileInputStream(path);
InputStreamReader isr=new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String line="";
while ((line=br.readLine())!=null) {
//arrs=line.split(",");
//System.out.println(arrs[0]);
System.out.println(line);
}
br.close();
isr.close();
fis.close();
}
获取系统时间
long begin = System.currentTimeMillis();
String Format
String str_accuracy=String.format(" accuracy = %.4f ", accuracy);