Guest User

Untitled

a guest
Nov 12th, 2014
258
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.*;
  2. import java.net.ServerSocket;
  3. import java.net.Socket;
  4.  
  5. public class Main{
  6.     public static void main(String[] args) {
  7.         My my=new My();
  8.         my.setVisible(true);
  9.         int a=0,size=0;
  10.  
  11.         try {
  12.             ServerSocket serverSocket=new ServerSocket(8888);
  13.             Socket socket=serverSocket.accept();
  14.             InputStream inputStream=socket.getInputStream();
  15.             OutputStream outputStream=socket.getOutputStream();
  16.  
  17.             while (true){
  18.                 if ((size=inputStream.available())!=0) {
  19.                     byte buf[] = new byte[size+100];
  20.                     inputStream.read(buf);
  21.                     File file = new File("Files/asd"+a+".txt");
  22.                     FileOutputStream fileOutputStream = new FileOutputStream(file);
  23.                     fileOutputStream.write(buf);
  24.                     fileOutputStream.close();
  25.                     my.jLabel.setText(String.valueOf((++a) + "     " + socket+"   "+size));
  26.                 }
  27.             }
  28.         } catch (IOException e) {
  29.             e.printStackTrace();
  30.         }
  31.     }
  32. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×