此文贴上一个刚学习网络编程的一个小练习:文件上传案例
客户端代码
public class Demo02Client {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("day12-code\\2.jpg");
Socket socket = new Socket("127.0.0.1", 8888);
OutputStream os = socket.getOutputStream();
int len = 0;
byte[] bytes = new byte[1024];
while((len = fis.read(bytes)) != -1) {
os.write(bytes, 0