FileHttpDownload extends FileHttpHandler { public void download(String http, String savaPath, String fileName, FileAction<File> fileAction) { download(http, savaPath, fileName, false, fileAction); }  void download(String http, String savaPath, String fileName, FileAction<File> fileAction); void download(String http, String savaPath, String fileName, boolean onlyReplaceName, FileAction<File> fileAction); void download(String http, String method, String savaPath, String fileName, boolean onlyReplaceName, FileAction<File> fileAction); void download(String http, String filePath, FileAction<File> fileAction); void download(String http, File saveFile, FileAction<File> fileAction); static String getFileNameFromUrl(String url); String getFileName(String http, String disposition, String fileName, boolean onlyReplaceName); String getFileNameO(String http, String disposition, String fileName, boolean onlyReplaceName); static void main(String[] arg);  }
@Test public void testUpload() { Map<String, String> dataMap = new HashMap<String, String>(); dataMap.put("userId", "110"); FileAction<File> action = new FileAction<File>() { @Override public void progress(long speed, long size, long finishSize, double progress) { String speedText = "0MB/s"; if (speed < 1024) { speedText = speed + "B/s"; } else if (1024 <= speed && speed < (1024 * 1024)) { String s = OnlyNumberUtil.format(((double) speed / 1024d)); speedText = s + "KB/s"; } else { String s = OnlyNumberUtil.format(((double) speed / (double) (1024 * 1024))); speedText = s + "MB/s"; } StringBuilder sb = new StringBuilder(); sb.append("size:" + size); sb.append(" "); sb.append("finishSize:" + finishSize); sb.append(" "); sb.append("progress:" + progress); sb.append(" "); sb.append("speed:"); sb.append(speedText); sb.append(" "); System.out.println(sb); } @Override public void success(File t) { System.out.println(t.getAbsolutePath()); } @Override public void lost(File t) { } }; String http = "http: String savaPath = "Temp/"; String fileName = ""; boolean onlyReplaceName = false; FileHttpDownload fhd = new FileHttpDownload(); fhd.download(http,"", savaPath, fileName, onlyReplaceName, action); }