推荐于2016-01-04 · 知道合伙人互联网行家
关注
展开全部
package test;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
BufferedReader br = null;
File f = null;
FileWriter fw = null;
BufferedWriter bw = null;
try {
f = new File("C:/test.log");
fw = new FileWriter(f,true);
bw = new BufferedWriter(fw);
for(;;){
System.out.println("please input your message:(exit to quit");
br=new BufferedReader(new InputStreamReader(System.in));
String a = br.readLine();
if("exit".equalsIgnoreCase(a)) break;
bw.write(a);
bw.flush();
bw.newLine();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
bw.close();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
BufferedReader br = null;
File f = null;
FileWriter fw = null;
BufferedWriter bw = null;
try {
f = new File("C:/test.log");
fw = new FileWriter(f,true);
bw = new BufferedWriter(fw);
for(;;){
System.out.println("please input your message:(exit to quit");
br=new BufferedReader(new InputStreamReader(System.in));
String a = br.readLine();
if("exit".equalsIgnoreCase(a)) break;
bw.write(a);
bw.flush();
bw.newLine();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
br.close();
bw.close();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询