Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class clientSend implements Runnable {
- public void run(){}
- private Socket fileSocket;
- public clientSend(String file) { //String host, int port, String file
- try {
- fileSocket = new Socket("192.168.0.17", 9092);
- sendFile(file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public void sendFile(String file) throws IOException {
- DataOutputStream outFrom = new DataOutputStream(fileSocket.getOutputStream());
- FileInputStream inputFrom = new FileInputStream(file);
- byte[] buffer = new byte[4096];
- while (inputFrom.read(buffer) > 0) {
- outFrom.write(buffer);
- }
- inputFrom.close();
- outFrom.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement