//Open a socket Socket socket = new Socket() ; OutputSteam opt = socket.getOutputStream ; File file = new File("test.txt") ; FileInputStream fis = new FileInputeStream(file) ; byte[] data = new byte[ 1024 * 16 ] ; int count ; while( (count = fis.read(data)) > 0){ opt.write(data , 0 , count) ; }