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

src.samples.java.ex.IOI_Sample Maven / Gradle / Ivy

Go to download

An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.

There is a newer version: 7.6.8
Show newest version
package ex;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.apache.commons.io.IOUtils;

public class IOI_Sample {

    public byte[] getIOIData(File f) throws IOException {
        try (InputStream is = new BufferedInputStream(new FileInputStream(f)); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {

            IOUtils.copy(is, baos);

            return baos.toByteArray();
        }
    }

    public byte[] getIOIReaderData(File f) throws IOException {
        try (FileReader r = new FileReader(f); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {

            IOUtils.copy(r, baos);

            return baos.toByteArray();
        }
    }

    public void copy(String inName, String outName) throws IOException {
        byte[] buf = new byte[1024];

        try (InputStream is = new FileInputStream(inName); OutputStream os = new FileOutputStream(outName);) {

            int size = is.read(buf);
            while (size >= 0) {
                os.write(buf, 0, size);
                size = is.read(buf);
            }
        }
    }

    class FPBofoStream extends FileInputStream {

        public FPBofoStream(File f) throws IOException {
            super(f);
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy