Here you can find the source of getFileAsByteArrayOutputStream( File file)
Parameter | Description |
---|---|
filename | a parameter |
Parameter | Description |
---|
public static ByteArrayOutputStream getFileAsByteArrayOutputStream( File file) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /**/*from w w w . ja v a 2 s.c o m*/ * * @return * @param filename * @throws java.io.IOException * @deprecated Used IOUtil.getFileAsByteArrayOutputStream */ public static ByteArrayOutputStream getFileAsByteArrayOutputStream( File file) throws IOException { InputStream in = null; String tmpFilename = null; OutputStream out = null; byte[] buf = new byte[1024 * 8]; int len = 0; try { // Open the file in = new FileInputStream(file); // Open the output byte array out = new ByteArrayOutputStream(); // Transfer bytes from the ZIP file to the output file while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } // Close the streams out.close(); in.close(); } catch (IOException e) { e.printStackTrace(); } return (ByteArrayOutputStream) out; } }