Answers for "java transfer file over socket"

0

java transfer file over socket

Socket socket =  new Socket() ; //Open a socket with the server
OutputSteam opt = socket.getOutputStream ; // get the outputStream of the socket 
// so we can write in it 
File file = new File(" Path of the file you want to send ") ; 
FileInputStream fis = new FileInputeStream(file) ; 

byte[] data = new byte[ 1024 * 16 ] ;
int count  ; 
while( (count  = fis.read(data))  > 0){
  opt.write(data , 0 , count) ; 
}
Posted by: Guest on April-17-2021

Code answers related to "java transfer file over socket"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language