Is this the best way to download a file in java?

后端 未结 4 1913
半阙折子戏
半阙折子戏 2021-01-07 07:20
public void download(String url, String destination) {
        BufferedOutputStream localBufferedOutputStream = null;
        URLConnection localURLConnection = null         


        
4条回答
  •  醉话见心
    2021-01-07 07:47

    It is certainly not the best way. Code that throws away all exceptions is rarely the best way to do any thing. You might also consider not usi g strings as parameters. URI and File would be good alternatives.

    If you want to copy streams transferTo is a good way.

提交回复
热议问题