Upload a file using HTTP put in Java

后端 未结 2 541
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-14 10:45

I am writing a desktop app in Java to upload a file to a folder on IIS server using HTTP PUT.

URLConnection urlconnection=null;
  try{
   File file = new Fil         


        
相关标签:
2条回答
  • 2021-01-14 11:32

    Possible bug: bis.read() can return a valid 0. You'll need to change the while condition to >= 0.

    0 讨论(0)
  • 2021-01-14 11:39

    After you complete the loop where you are writing the BufferedOutputStream, call bos.close(). That flushes the buffered data before closing the stream.

    0 讨论(0)
提交回复
热议问题