Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String dirPath = ...;
- ServerSocket serverSocket = ...;
- Socket socket = serverSocket.accept();
- BufferedInputStream bis = new BufferedInputStream(socket.getInputStream());
- DataInputStream dis = new DataInputStream(bis);
- int filesCount = dis.readInt();
- File[] files = new File[filesCount];
- for(int i = 0; i < filesCount; i++)
- {
- long fileLength = dis.readLong();
- String fileName = dis.readUTF();
- files[i] = new File(dirPath + "/" + fileName);
- FileOutputStream fos = new FileOutputStream(files[i]);
- BufferedOutputStream bos = new BufferedOutputStream(fos);
- for(int j = 0; j < fileLength; j++) bos.write(bis.read());
- bos.close();
- }
- dis.close();
Add Comment
Please, Sign In to add comment