本帖最后由 殷士剑 于 2012-11-23 12:40 编辑
- import java.io.BufferedReader;
- import java.io.FileWriter;
- import java.io.InputStreamReader;
- public class Test6 {
- /**
- * 从键盘输入一些字,然后被保存到一个指定的目录下,比如一个 demo.txt中
- */
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
- BufferedReader bufferedReader = new BufferedReader(
- new InputStreamReader(System.in));
- FileWriter out = new FileWriter("e:\\test\\log.txt");
- char[] buffer = new char[1024];
- int len = 0;
- while ((len = bufferedReader.read(buffer)) != -1) {
- out.write(buffer, 0, len);
- }
- bufferedReader.close();
- out.close();
- }
- }
复制代码 从控制台上输入后,在log.txt中没内容,我的代码错了吗? |