不知道为什么,这个程序变无限循环了。实在看不出那里有问题。有谁能帮我分析下吗?
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.Socket;
public class test
{
public static void main(String[] args) throws Exception
{
Socket socket=new Socket("192.168.42.89", 10000);
FileInputStream fS = new FileInputStream("d:\\eclipse-zh_3.5.0.zip");
OutputStream os = socket.getOutputStream();
byte[] b=new byte[1024];
int len=0;
while ((len=fS.read())!=-1)
{
System.out.println(len);
os.write(b, 0, len);
}
fS.close();
socket.shutdownOutput();
os.close();
}
} |
|