展开全部
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String filepath = "D:\\test.txt";
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filepath)));
String lin = "";
while (!(lin = br.readLine()).equals("exit")) {
bw.write(lin);
bw.newLine();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(bw != null){
bw.flush();
bw.close();
}
if(br != null)
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
展开全部
scanner scan = new scanner(system.in);
String str = scan.readLine();
File file = new File ("c:/aa.text");
FileInputStream 数据流写入
String str = scan.readLine();
File file = new File ("c:/aa.text");
FileInputStream 数据流写入
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询