構造Url
//url示例http://192.168.2.13:18080/api/proxy/download/cutRecord?app=51342330001328100004&stream=51342330001328100004&startTime=2021-10-18%2010%3A10%3A01&seconds=10
String buildUrl = UrlBuilder.create()
.setScheme("http") //http方式
.setHost("192.168.2.13") //ip
.setPort("18080") //端口
.addPath("/api").addPath("proxy").addPath("download").addPath("cutRecord")
.addQuery("app","51342330001328100004")
.addQuery("stream","51342330001328100004")
.addQuery("startTime","2021-10-18 10:10:01")
.addQuery("seconds","10")
.setCharset(Charset.forName(CharsetUtil.UTF_8)) //這里需要對傳的2021-10-18 10:10:01 UrlEncode編碼
.build();
long file = HttpUtil.downloadFile(buildUrl, "d:/test02.mp4"); //下載並創建d:/test02.mp4