Guest User

Untitled

a guest
Oct 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.InputStream;
  3. import java.net.Socket;
  4.  
  5. public class Connection {
  6.  
  7. public String SomeData;
  8. public Socket DataSocket;
  9. public InputStream xyz;
  10.  
  11. public Connection(String SomeData, String address) throws IOException {
  12. DataSocket = new Socket(address, 10000);
  13. }
  14.  
  15. public void connect(){
  16. try {
  17. xyz = DataSocket.getInputStream();
  18. } catch (IOException e) {
  19. e.printStackTrace();
  20. }
  21. }
  22.  
  23. public void read() throws IOException {
  24. byte[] data = new byte[10];
  25. xyz.read(data);
  26. SomeData = new String(data);
  27. }
  28.  
  29. public void close() throws IOException {
  30. xyz.close();
  31. }
  32.  
  33. }
Add Comment
Please, Sign In to add comment