2008-03-29, 02:27 PM
|
#2 (permalink)
|
長老會員
|
語法:
public static void main(String args[]) throws IOException
{
BufferedReader buf;
String str;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Input a string:\n");
FileWriter fw=new FileWriter("a1.txt");
BufferedWriter bfw=new BufferedWriter(fw);
boolean isExit = false;
while(!isExit){
str=buf.readLine();
if(str != null && !"EXIT".equalsIgnoreCase(str)){
bfw.write(str);
bfw.newLine();
bfw.flush();
}else{
isExit = true;
}
}
fw.close();
}
|
|
|
送花文章: 796,
收花文章: 7 篇, 收花: 11 次
|