### Question:
BufferedIoUtils { public static void writeInputStreamToFile(InputStream in, int bufSize, File targetFile) { int properBufferSize = properBufferSize(bufSize); byte[] buf = new byte[properBufferSize]; BufferedInputStream bin = null; FileOutputStream fout = null; try { bin = new BufferedInputStream(in); fout = new FileOutputStream(targetFile); int read; while ((read = bin.read(buf)) != -1) { System.out.println(read); fout.write(buf, 0, read); } } catch (IOException e) { e.printStackTrace(); } finally { if (bin != null) { try { bin.close(); } catch (IOException e) { e.printStackTrace(); } } if (fout != null) { try { fout.close(); } catch (IOException e) { e.printStackTrace(); } } } }  static void readInputStream(InputStream in, int bufSize, Callback<byte[]> callback); static void writeInputStreamToFile(InputStream in, int bufSize, File targetFile);  }### Answer:
@Test public void test() { try { URL url = new URL(path); HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); InputStream inputStream = httpConn.getInputStream(); BufferedIoUtils.writeInputStreamToFile(inputStream, 1024, new File(SystemUtils.getUserHome(), "tmp/SwiftGantt_0.4.0_release_withdemo.zip")); } catch (Exception e) { e.printStackTrace(); } }
@Test public void testReadFileWriteFile() { try { File readFile = new File(SystemUtils.getUserHome(), "password.txt"); InputStream inputStream = new FileInputStream(readFile); BufferedIoUtils.writeInputStreamToFile(inputStream, 1024, new File(SystemUtils.getUserHome(), "tmp/password.txt")); } catch (Exception e) { e.printStackTrace(); } }