BufferedOutputStream out=new BufferedOutputStream(new DataOutputStream(new FileOutputStream("输出的文件名")));int temp;
while((temp=DIS.read())!=-1)
out.write(temp)
out.close();
while((temp=DIS.read())!=-1)
out.write(temp)
out.close();
PrintWriter hqh=new PrintWriter(new FileWriter("hqh.dat"));
writeData(DIS,hqh);
hqh.close;static void writeData(DataInputStream DIS,PrintWriter hqh) throws IOException
{
int i;
for(i=0;i<DIS.length;i++)
{
char ch=0;
ch=DIS.charAt(i);
hqh.writeChar(ch);
}
}
错误提示为:E:\j2sdk1.4.0\program\communication\myserver.java:55: illegal start of expression
static void writeData(DataInputStream DIS,PrintWriter hqh) throws IOException
^
E:\j2sdk1.4.0\program\communication\myserver.java:53: cannot resolve symbol
symbol : method writeData (java.io.DataInputStream,java.io.PrintWriter)
location: class myserver
writeData(DIS,hqh);
你照着试试吧!不过我觉得好像你的问题不在这个地方!我觉得好像在static 上,你把它去掉试试看!
CyberH() 的方法,编译室可以通过的,不过若是在处理输入流(DataInputStream DIS)前写入文件,则服务器端和客户端相互等待,程序执行不下去;若在处理输入流后写入文件,则程序可以执行,但文件内容为空。