Search in sources :

Example 71 with Out

use of org.h2.dev.util.BinaryArithmeticStream.Out in project h2database by h2database.

the class TestStreams method testLZFStreamClose.

private void testLZFStreamClose() throws IOException {
    String fileName = getBaseDir() + "/temp";
    FileUtils.createDirectories(FileUtils.getParent(fileName));
    OutputStream fo = FileUtils.newOutputStream(fileName, false);
    LZFOutputStream out = new LZFOutputStream(fo);
    out.write("Hello".getBytes());
    out.close();
    InputStream fi = FileUtils.newInputStream(fileName);
    LZFInputStream in = new LZFInputStream(fi);
    byte[] buff = new byte[100];
    assertEquals(5, in.read(buff));
    in.read();
    in.close();
    FileUtils.delete(getBaseDir() + "/temp");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LZFInputStream(org.h2.compress.LZFInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LZFOutputStream(org.h2.compress.LZFOutputStream) LZFInputStream(org.h2.compress.LZFInputStream) LZFOutputStream(org.h2.compress.LZFOutputStream)

Example 72 with Out

use of org.h2.dev.util.BinaryArithmeticStream.Out in project h2database by h2database.

the class FileReorderWrites method open.

@Override
public FileChannel open(String mode) throws IOException {
    InputStream in = newInputStream();
    FilePath copy = FilePath.get(getBase().toString() + ".copy");
    OutputStream out = copy.newOutputStream(false);
    IOUtils.copy(in, out);
    in.close();
    out.close();
    FileChannel base = getBase().open(mode);
    FileChannel readBase = copy.open(mode);
    return new FileReorderWrites(this, base, readBase);
}
Also used : FilePath(org.h2.store.fs.FilePath) InputStream(java.io.InputStream) FileChannel(java.nio.channels.FileChannel) OutputStream(java.io.OutputStream)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)27 IOException (java.io.IOException)23 OutputStream (java.io.OutputStream)19 ByteArrayInputStream (java.io.ByteArrayInputStream)17 SQLException (java.sql.SQLException)17 DbException (org.h2.message.DbException)17 Random (java.util.Random)11 ResultSet (java.sql.ResultSet)10 InputStream (java.io.InputStream)9 Statement (java.sql.Statement)9 Connection (java.sql.Connection)7 PrintStream (java.io.PrintStream)6 Properties (java.util.Properties)6 Task (org.h2.util.Task)6 BufferedOutputStream (java.io.BufferedOutputStream)5 File (java.io.File)5 FileOutputStream (java.io.FileOutputStream)5 InputStreamReader (java.io.InputStreamReader)5 PipedInputStream (java.io.PipedInputStream)5 OutputStreamWriter (java.io.OutputStreamWriter)4