Example usage for org.apache.http.util ByteArrayBuffer ByteArrayBuffer

List of usage examples for org.apache.http.util ByteArrayBuffer ByteArrayBuffer

Introduction

In this page you can find the example usage for org.apache.http.util ByteArrayBuffer ByteArrayBuffer.

Prototype

public ByteArrayBuffer(int i) 

Source Link

Usage

From source file:TDS.Proctor.Services.EmbossFileService.java

/**
 * Combine one or more files into a new file with page breaks.
 *
 * @param files one or more file paths to braille files that will be combined with page breaks
 * @return the combined file contents as a byte array
 * @throws IOException/* w  ww. j a  v  a  2s .com*/
 */
public byte[] combineFiles(String[] files) throws IOException {
    ByteArrayBuffer contents = new ByteArrayBuffer(0);

    byte[] bytes = IOUtils.toByteArray(contentRepository.findResource(files[0]));
    contents.append(bytes, 0, bytes.length);

    for (int i = 1; i < files.length; i++) {
        // page break
        contents.append(PAGE_BREAK_BYTES, 0, PAGE_BREAK_BYTES.length);

        bytes = IOUtils.toByteArray(contentRepository.findResource(files[i]));
        contents.append(bytes, 0, bytes.length);
    }

    return contents.toByteArray();
}