java - Server sending Empty file to client -


सर्वर साइड कोड

  int count = -1; बाइट [] मायबाइटियररे = नवा बाइट [1024]; BufferedInputStream bis = नया BufferedInputStream (नई FileInputStream (myFile)); ओएस = s.getOutputStream (); System.out.println ("भेजा जा रहा है + + फ़ाइलनाम +" ("+ mybytearray.length +" बाइट्स) "); जबकि ((गणना = (बीआईएस.रेड (मायबाइटिएरे)))> 0) {System.out.println (गणना); os.write (mybytearray, 0, गिनती); os.flush (); } System.out.println ("संपन्न"); bis.close (); os.close ();   

क्लाइंट साइड कोड

  int bytesRead = -1; बाइट [] मायबाइटियररे = नवा बाइट [1024]; InputStream isP = p2p.getInputStream (); FileOutputStream fos = नया FileOutputStream (पथ + "आरएफसी" + आरएफसीएनम + ".txt"); जबकि ((बाइट्स रीड = आईपीपी। रीड (मायबाइटिएरे)) gt; 0) {fos.write (mybytearray, 0, बाइट्स रीड); fos.flush (); FILESIZE + = bytesRead; } System.out.println ("फ़ाइल का आकार" + फ़ाइल आकार है); isP.close (); fos.close ();   

मुझे सर्वर से क्लाइंट तक एक रिक्त फाइल मिल रही है हालांकि सर्वर पर यह बायटाईयर आकार छपाई कर रहा है जो शून्य नहीं है। क्या कोई मुझे इस से मदद कर सकता है?

उस कोड के साथ, फ़ाइल को सर्वर पर भी खाली होना चाहिए।

भले ही सर्वर पर यह बायटाईरे आकार छपाई कर रहा है शून्य नहीं।

ऐसा इसलिए है क्योंकि आपने इसे 'नए बाइट [1024]' के रूप में आरंभ किया था फ़ाइल की लंबाई के साथ इसका कोई लेना देना नहीं है।

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -