黑马程序员技术交流社区
标题:
请看以下代码,看错在那里,我一直搞不明白啊
[打印本页]
作者:
endian11
时间:
2014-6-28 06:50
标题:
请看以下代码,看错在那里,我一直搞不明白啊
import java.io.*;
import java.net.*;
class client
{
public static void main(String[] args) throws Exception
{
Socket s = new Socket("192.168.1.100",3000);
OutputStream out = s.getOutputStream();
//BufferedOutputStream bo = new BufferedOutputStream(out);
byte[] b = new byte[1024];
BufferedInputStream bi = new BufferedInputStream(new FileInputStream("d:\\1.jpg"));
int len = 0;
System.out.println("Hello World!");
while ((len = bi.read(b) ) != -1)
{
out.write( b, 0, len);
}
}
}
class sever
{
public static void main(String[] args) throws Exception
{
ServerSocket s = new ServerSocket(3000);
Socket ss = s.accept();
InputStream in = ss.getInputStream();
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream("d:\\2.jpg"));
byte[] b = new byte[1024];
// BufferedInputStream bi = new BufferedInputStream(new FileInputStream("c:\\1.jpg"));
int len = 0;
while ((len = in.read(b) ) != -1)
{
bo.write( b, 0, len);
bo.flush();
}
System.out.println("Hello World!");
}
}
out.write( b, 0, len);
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2