All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nuecho.rivr.voicexml.util.IOUtils Maven / Gradle / Ivy

Go to download

Rivr is a lightweight open-source dialogue engine enabling flexible VoiceXML web application development for the agile Java developer and enterprise.

There is a newer version: 1.0.13
Show newest version
/*
 * Copyright (c) 2013 Nu Echo Inc. All rights reserved.
 */

package com.nuecho.rivr.voicexml.util;

import java.io.*;

import com.nuecho.rivr.core.util.*;

/**
 * IO utility class.
 * 
 * @author Nu Echo Inc.
 */
public final class IOUtils {

    private static final int BUFFER_SIZE = 4096;

    public static byte[] toByteArray(InputStream inputStream) throws IOException {
        Assert.notNull(inputStream, "inputStream");
        byte[] buffer = new byte[BUFFER_SIZE];
        InputStream bufferedInputStream = new BufferedInputStream(inputStream, BUFFER_SIZE);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        int length = 0;
        while ((length = bufferedInputStream.read(buffer, 0, BUFFER_SIZE)) != -1) {
            outputStream.write(buffer, 0, length);
        }

        return outputStream.toByteArray();
    }

    private IOUtils() {}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy