关于流的问题 Stream是面向byte的。reader/writer是面向字符的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你好,能不能给一个键盘输入个人资料,包括姓名\身份证\住址\Email地址,并将其写入一个.txt文件的实例,让我更好的理解流.谢谢 OutputStream、InputStream 是抽象类,我们在实际开发中很少使用的,流是为了不依赖硬件而设计的,但我觉得流最好是理解为管道,只要适合就可以通过参数套接使用,当然每个流有不同的用途。 import java.io.*;import java.net.*;public class TestChar { public static void main(String[] args){ BufferedReader in = null; FileWriter out = null; try { while(true){ //建立緩存﹐并轉化為雙字節字符形式 in = new BufferedReader( new InputStreamReader(System.in)); out = new FileWriter("e:\\abbcc.txt",true); String line; line = in.readLine(); //當輸入'bye'時退出 if (line.equalsIgnoreCase("bye")) break; //加入換行符 out.write(line+"\r\n"); out.flush(); } } catch (IOException ex) { } finally{ try { //關閉流 if (in != null) { in.close(); } if (out != null) { out.close(); } } catch (IOException ex1) { } } }} 谢谢大家的帮助!要是给个键盘输入个人资料(姓名,QQ号,Email)然后写入文件的例子,剩下的30分全送了,呵呵, jna怎么做钩子啊。。。想搞个拦截关机的程序,哪位高手做过支个招!!谢谢哩。 log4j的问题 关于错误处理 游戏中报文的进制一般是选用16进制还是10进制 请教高手AWT的图片显示问题 ==========JAVA 的一个进程是否最多只能占用一个CPU的资源========== Java 新手求助 (关于包的问题)请问这怎么不能compile! 菜鸟必读1:AWT与Swing的区别(欢迎收藏) 求教Java SE中集合框架查询的方法 打成 jar 包后,在没有安装 JDK 的机器上可以运行吗? 菜鸟问题来这又分,叫个朋友!
import java.net.*;public class TestChar {
public static void main(String[] args){
BufferedReader in = null;
FileWriter out = null;
try {
while(true){
//建立緩存﹐并轉化為雙字節字符形式
in = new BufferedReader(
new InputStreamReader(System.in));
out = new FileWriter("e:\\abbcc.txt",true);
String line;
line = in.readLine();
//當輸入'bye'時退出
if (line.equalsIgnoreCase("bye")) break;
//加入換行符
out.write(line+"\r\n");
out.flush();
}
}
catch (IOException ex) {
}
finally{
try {
//關閉流
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
catch (IOException ex1) {
}
} }
}
要是给个键盘输入个人资料(姓名,QQ号,Email)然后写入文件的例子,剩下的30分全送了,呵呵,