use of java.io.FilterOutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_ConstructorLjava_io_OutputStream.
public void test_ConstructorLjava_io_OutputStream() {
// Test for method java.io.FilterOutputStream(java.io.OutputStream)
try {
bos = new ByteArrayOutputStream();
os = new FilterOutputStream(bos);
os.write('t');
} catch (java.io.IOException e) {
fail("Constructor test failed : " + e.getMessage());
}
}
use of java.io.FilterOutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_write$BII_Exception.
public void test_write$BII_Exception() throws IOException {
Support_OutputStream sos = new Support_OutputStream(testLength);
os = new FilterOutputStream(sos);
byte[] buf = new byte[10];
try {
os.write(buf, -1, 1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
os.write(buf, 0, -1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
try {
os.write(buf, 10, 1);
fail("IndexOutOfBoundsException expected.");
} catch (IndexOutOfBoundsException e) {
// Expected.
}
}
use of java.io.FilterOutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_write$BII.
public void test_write$BII() throws IOException {
Support_OutputStream sos = new Support_OutputStream(testLength);
os = new FilterOutputStream(sos);
os.write(fileString.getBytes(), 10, testLength - 10);
bis = new ByteArrayInputStream(sos.toByteArray());
assertTrue("Test 1: Bytes have not been written.", bis.available() == testLength - 10);
byte[] wbytes = new byte[testLength - 10];
bis.read(wbytes);
assertTrue("Test 2: Incorrect bytes written or read.", fileString.substring(10).equals(new String(wbytes)));
try {
// Support_OutputStream throws an IOException if the internal
// buffer is full, which it should be eventually.
os.write(fileString.getBytes());
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of java.io.FilterOutputStream in project robovm by robovm.
the class OldFilterOutputStreamTest method test_writeI.
public void test_writeI() throws IOException {
Support_OutputStream sos = new Support_OutputStream(1);
os = new FilterOutputStream(sos);
os.write(42);
bis = new ByteArrayInputStream(sos.toByteArray());
assertTrue("Test 1: Byte has not been written.", bis.available() == 1);
assertEquals("Test 2: Incorrect byte written or read;", 42, bis.read());
try {
// Support_OutputStream throws an IOException if the internal
// buffer is full, which it should be now.
os.write(42);
fail("Test 2: IOException expected.");
} catch (IOException e) {
// Expected.
}
}
use of java.io.FilterOutputStream in project voldemort by voldemort.
the class VoldemortAdminTool method writeBinary.
private static void writeBinary(File outputFile, Printable printable) throws IOException {
OutputStream outputStream = null;
if (outputFile == null) {
outputStream = new FilterOutputStream(System.out) {
@Override
public void close() throws IOException {
flush();
}
};
} else {
outputStream = new FileOutputStream(outputFile);
}
DataOutputStream dataOutputStream = new DataOutputStream(new BufferedOutputStream(outputStream));
try {
printable.printTo(dataOutputStream);
} finally {
dataOutputStream.close();
}
}
Aggregations