sockets - Java File Transfer getting stuck halfway -


I am trying to send a file (sent as an image byte array) with the customer and then the server However, when I click on "Send" to send the image, then File Transfer starts (as I get sentImage.jpg in my desktop), but this is anybody Is stuck for the reason that I am not able to understand The image is not sent correctly

The part that is received from the server is here (this connection has already been accepted):

  Public run zero () {try {byte [] receivedData = new byte [1024]; BufferedInputStream bis = new BufferedInputStream (client.getInputStream ()); // while (bis.)! = -1) {s.acquire unintupt (); BufferedOutputStream Boss = New BufferedOutputStream (New FileOutputStream ("C: \\ User \\ Desktop \\ sentImage.jpg");); While ((Inward = BIS read (Received Data))! = -1) {Bose Written (received data, 0, incoming); } S.release (); N.release (); Bis.close (); Bos.flush (); //}} hold (IOException e) {e.printStackTrace (); }}  

and the customer is sending it here:

  Public Zero sendImageResult () {New Thread (New Runnabel) {Public Zero Run} {{ Int inside = 0; Socket socket = new socket ("localhost", 4444), file myImageFile = new file ("C: \\ user \\ administrator \\ desktop \\ test.jpg"); BufferedInputStream bis = new BufferedInputStream (New FileInputStream (myImageFile)); BufferedOutputStream bos = newBuffferedOutputStream (socket.getOutputStream ()); Byte [] bytere = new byte [1024]; While ((inside = bis pad (byte))! = -1) {Bos.write (byte, 0, inside);} bis.close (); Bos.flush ();} hold (unknown host exception before) {System.out.println ("No Pudo Estescator La Concease."); Ex.printStackTrace (); } Grip (Filenotfound Express FNF) {FnF.PrintsTextress (); } Hold (IOException ioe) {io.printStackTrace (); }                  }             }).Start(); }  

It does not seem that the output is used to write (Bose) Closing the disc can have unexpected results.


Comments

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

iphone - How do I make a UIPickerView in a UIActionSheet -