@Test public void testCopy2null() throws IOException { ByteArrayInputStream stringIS = new ByteArrayInputStream(source.getBytes()); IO.copy2null(stringIS, 10); String filename = TestNcmlRead.topDir + "aggExisting.xml"; try (FileInputStream fos = new FileInputStream(filename); FileChannel channel = fos.getChannel()) { IO.copy2null(channel, 10); } }
public static long copy2null(InputStream in, int buffersize) throws IOException { long totalBytesRead = 0; if (buffersize <= 0) buffersize = default_file_buffersize; byte[] buffer = new byte[buffersize]; while (true) { int n = in.read(buffer); if (n == -1) break; totalBytesRead += n; } return totalBytesRead; }
IO { public static long copy2null(InputStream in, int buffersize) throws IOException { long totalBytesRead = 0; if (buffersize <= 0) buffersize = default_file_buffersize; byte[] buffer = new byte[buffersize]; while (true) { int n = in.read(buffer); if (n == -1) break; totalBytesRead += n; } return totalBytesRead; } }
IO { public static long copy2null(InputStream in, int buffersize) throws IOException { long totalBytesRead = 0; if (buffersize <= 0) buffersize = default_file_buffersize; byte[] buffer = new byte[buffersize]; while (true) { int n = in.read(buffer); if (n == -1) break; totalBytesRead += n; } return totalBytesRead; }  }
IO { public static long copy2null(InputStream in, int buffersize) throws IOException { long totalBytesRead = 0; if (buffersize <= 0) buffersize = default_file_buffersize; byte[] buffer = new byte[buffersize]; while (true) { int n = in.read(buffer); if (n == -1) break; totalBytesRead += n; } return totalBytesRead; }  @Nullable static InputStream getFileResource(String resourcePath); static long copy(InputStream in, OutputStream out); static long copyBuffered(InputStream in, OutputStream out, int buffer_size); static long copy2null(InputStream in, int buffersize); static long copy2null(FileChannel in, int buffersize); static long copyB(InputStream in, OutputStream out, int bufferSize); static void copyMaxBytes(InputStream in, OutputStream out, int maxBytes); static String readContents(InputStream is); static String readContents(InputStream is, String charset); static byte[] readContentsToByteArray(InputStream is); static void writeContents(String contents, OutputStream os); static void copyFile(String fileInName, String fileOutName); static void copyFile(File fileIn, File fileOut); static void copy2File(byte[] src, String fileOut); static void copyFile(String fileInName, OutputStream out); static void copyFileB(File fileIn, OutputStream out, int bufferSize); static long copyRafB(ucar.unidata.io.RandomAccessFile raf, long offset, long length, OutputStream out,
      byte[] buffer); static void copyDirTree(String fromDirName, String toDirName); static byte[] readFileToByteArray(String filename); static String readFile(String filename); static void writeToFile(String contents, File file); static void writeToFile(byte[] contents, File file); static void writeToFile(String contents, String fileOutName); static long writeToFile(InputStream in, String fileOutName); static long appendToFile(InputStream in, String fileOutName); }
IO { public static long copy2null(InputStream in, int buffersize) throws IOException { long totalBytesRead = 0; if (buffersize <= 0) buffersize = default_file_buffersize; byte[] buffer = new byte[buffersize]; while (true) { int n = in.read(buffer); if (n == -1) break; totalBytesRead += n; } return totalBytesRead; }  @Nullable static InputStream getFileResource(String resourcePath); static long copy(InputStream in, OutputStream out); static long copyBuffered(InputStream in, OutputStream out, int buffer_size); static long copy2null(InputStream in, int buffersize); static long copy2null(FileChannel in, int buffersize); static long copyB(InputStream in, OutputStream out, int bufferSize); static void copyMaxBytes(InputStream in, OutputStream out, int maxBytes); static String readContents(InputStream is); static String readContents(InputStream is, String charset); static byte[] readContentsToByteArray(InputStream is); static void writeContents(String contents, OutputStream os); static void copyFile(String fileInName, String fileOutName); static void copyFile(File fileIn, File fileOut); static void copy2File(byte[] src, String fileOut); static void copyFile(String fileInName, OutputStream out); static void copyFileB(File fileIn, OutputStream out, int bufferSize); static long copyRafB(ucar.unidata.io.RandomAccessFile raf, long offset, long length, OutputStream out,
      byte[] buffer); static void copyDirTree(String fromDirName, String toDirName); static byte[] readFileToByteArray(String filename); static String readFile(String filename); static void writeToFile(String contents, File file); static void writeToFile(byte[] contents, File file); static void writeToFile(String contents, String fileOutName); static long writeToFile(InputStream in, String fileOutName); static long appendToFile(InputStream in, String fileOutName); static final int default_file_buffersize; static final int default_socket_buffersize; }