Java ByteArrayOutputStream Write loadProbe(InputStream in, int buffSize)

Here you can find the source of loadProbe(InputStream in, int buffSize)

Description

load Probe

License

Apache License

Declaration

public static byte[] loadProbe(InputStream in, int buffSize) throws IOException 

Method Source Code


//package com.java2s;
/*/*from   w w w  .  j  av a 2  s.c o  m*/
 * Copyright 2012 Krzysztof Otrebski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.*;

public class Main {
    public static byte[] loadProbe(InputStream in, int buffSize) throws IOException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        byte[] buff = new byte[buffSize];
        int read = in.read(buff);
        if (read > 0) {
            bout.write(buff, 0, read);
        }
        return bout.toByteArray();
    }
}

Related

  1. loadAsText(Class cls, String name)
  2. loadBinFile(java.io.File f)
  3. loadFully(final InputStream aStream)
  4. loadIfileAsBytes(final IFile ifile)
  5. loadIntoMemory(InputStream is)
  6. loadStream(InputStream in, String encoding)
  7. readAll(File file)
  8. readAll(InputStream aInputStream)
  9. readAll(InputStream bytes)