标题:输出问题
只看楼主
叶兵
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-4-14
 问题点数:0 回复次数:2 
输出问题
import java.io.*;
public class IOStreamdemo{
public static void main(String [] args)throws IOException{
BufferedReader in=
new BufferedReader(
new FileReader("IOStreamdemo.java"));
String s ,s2=new String();
while((s=in.readLine())!=null)
s2+=s+"\n";
System.out.println(s2);
in.close();
BufferedReader stdin=
new BufferedReader(
new InputStreamReader(System.in));
System.out.println(stdin.readLine());
StringReader in2=new StringReader(s2);
int c;
while((c=in2.read())!=-1)
System.out.print((char)c);
DataInputStream in3=
new DataInputStream(
new ByteArrayInputStream(s2.getBytes()));
while(in3.available()!=0)
System.out.print((char)in3.readByte());
try{
BufferedReader in4=
new BufferedReader(
new StringReader(s2));
PrintWriter out1=
new PrintWriter(
new BufferedWriter(
new FileWriter("E/IODemo.txt")));/*这有问题*/
int linecount=1;
while((s=in4.readLine())!=null)
out1.println(linecount++ + ":" +s);
out1.close();
}catch(EOFException e){
System.out.println("end of stream");
}
}
}
我想把他输入到e下的IODemo.txt的文件中怎么弄啊 如果是写成IODemo.txt 他直接就放在了当前目录下了 我初学java不懂啊.
搜索更多相关主题的帖子: new String java System 
2007-10-22 00:06
netstriker
Rank: 1
等 级:新手上路
威 望:1
帖 子:257
专家分:0
注 册:2007-3-24
得分:0 
new BufferedReader(
new StringReader(s2));
PrintWriter out1=
new PrintWriter(
new BufferedWriter(
new FileWriter("E/IODemo.txt"))); //这样就可以了 new FileWriter("E:\\IODemo.txt")));
int linecount=1;
while((s=in4.readLine())!=null)
out1.println(linecount++ + ":" +s);
out1.close();
}catch(EOFException e){
System.out.println("end of stream");
}
}
2007-10-22 00:52
叶兵
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2006-4-14
得分:0 

谢谢了!!!


I believe i can
2007-10-22 21:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-179675-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021469 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved