F
fff2001
Unregistered / Unconfirmed
GUEST, unregistred user!
程序中想把一些有用信息写到txt文件中,初步的想法是通过fileWriter类创建,但由于java
懂得不是很多,所以很难丰富,想请各位帮忙:
import java.io.*;
import java.util.Date;
import java.lang.String;
import java.text.SimpleDateFormat;
public class WriteLog {
// public static void main(String[] args) {
public WriteLog(){}
static void WriteMsg(String line){
try {
SimpleDateFormat formatter = new SimpleDateFormat ("MMdd_yy");
Date currentTime_1 = new Date();
String dateString = formatter.format(currentTime_1);
String filename = "Log"+dateString ;
FileWriter output = new FileWriter(filename);
// output.write(line, 0, line.length());
String str="";
str=str + line;
output.write(str+ "/r");
// Output.newLine();
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
懂得不是很多,所以很难丰富,想请各位帮忙:
import java.io.*;
import java.util.Date;
import java.lang.String;
import java.text.SimpleDateFormat;
public class WriteLog {
// public static void main(String[] args) {
public WriteLog(){}
static void WriteMsg(String line){
try {
SimpleDateFormat formatter = new SimpleDateFormat ("MMdd_yy");
Date currentTime_1 = new Date();
String dateString = formatter.format(currentTime_1);
String filename = "Log"+dateString ;
FileWriter output = new FileWriter(filename);
// output.write(line, 0, line.length());
String str="";
str=str + line;
output.write(str+ "/r");
// Output.newLine();
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}