当前位置: 首页>>代码示例>>Java>>正文


Java FilterOutputStream.write方法代码示例

本文整理汇总了Java中java.io.FilterOutputStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java FilterOutputStream.write方法的具体用法?Java FilterOutputStream.write怎么用?Java FilterOutputStream.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.FilterOutputStream的用法示例。


在下文中一共展示了FilterOutputStream.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_flush

import java.io.FilterOutputStream; //导入方法依赖的package包/类
public void test_flush() throws IOException {
    Support_OutputStream sos = new Support_OutputStream(550);
    os = new FilterOutputStream(sos);
    os.write(fileString.getBytes(), 0, 500);
    os.flush();
    assertEquals("Test 1: Bytes not written after flush;",
            500, sos.size());

    sos.setThrowsException(true);
    try {
        os.flush();
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
    sos.setThrowsException(false);
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:18,代码来源:OldFilterOutputStreamTest.java

示例2: Support_OutputStream

import java.io.FilterOutputStream; //导入方法依赖的package包/类
public void test_write$B() throws IOException {
    Support_OutputStream sos = new Support_OutputStream(testLength);
    os = new FilterOutputStream(sos);
    os.write(fileString.getBytes());

    bis = new ByteArrayInputStream(sos.toByteArray());
    assertTrue("Test 1: Bytes have not been written.",
            bis.available() == testLength);
    byte[] wbytes = new byte[testLength];
    bis.read(wbytes, 0, testLength);
    assertTrue("Test 2: Incorrect bytes written or read.",
            fileString.equals(new String(wbytes)));

    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.
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:23,代码来源:OldFilterOutputStreamTest.java

示例3: test_writeI

import java.io.FilterOutputStream; //导入方法依赖的package包/类
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.
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:21,代码来源:OldFilterOutputStreamTest.java

示例4: FilterOutputStream

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#FilterOutputStream(java.io.OutputStream)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies FilterOutputStream(java.io.OutputStream) constructor.",
    method = "FilterOutputStream",
    args = {java.io.OutputStream.class}
)
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());
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:20,代码来源:FilterOutputStreamTest.java

示例5: test_flush

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#flush()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "flush",
    args = {}
)
public void test_flush() throws IOException {
    Support_OutputStream sos = new Support_OutputStream(550);
    os = new FilterOutputStream(sos);
    os.write(fileString.getBytes(), 0, 500);
    os.flush();
    assertEquals("Test 1: Bytes not written after flush;",
            500, sos.size());

    sos.setThrowsException(true);
    try {
        os.flush();
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
    sos.setThrowsException(false);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:FilterOutputStreamTest.java

示例6: test_writeI

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#write(int)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "write",
    args = {int.class}
)
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.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:29,代码来源:FilterOutputStreamTest.java

示例7: writeZipFile

import java.io.FilterOutputStream; //导入方法依赖的package包/类
private void writeZipFile(File baseDir, File archive, List<String> files) throws FileNotFoundException, IOException {
	FilterOutputStream out = null;
	ZipOutputStream stream = new ZipOutputStream(new FileOutputStream(archive));
	stream.setLevel(Deflater.DEFAULT_COMPRESSION);
	out = stream;

	byte data[] = new byte[18024];

	for (String f : files) {
		logger.info(String.format("Writing %s to ZIP archive %s", f, archive));
		((ZipOutputStream) out).putNextEntry(new ZipEntry(f));

		BufferedInputStream in = new BufferedInputStream(new FileInputStream(new File(baseDir, f)));

		int len = 0;
		while ((len = in.read(data)) > 0) {
			out.write(data, 0, len);
		}

		out.flush();
		in.close();
	}

	out.close();
}
 
开发者ID:lizardtechblog,项目名称:ExpressZip,代码行数:26,代码来源:Job.java

示例8: sendMessage

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * 
 * @param socket
 * @param message
 * @throws IOException 
 */
public void sendMessage(Socket socket, String message) throws IOException {
	FilterOutputStream fos = new FilterOutputStream(socket.getOutputStream());

	String send;
       send = String.format(Locale.US, message);        	

	fos.write(send.getBytes("US-ASCII"));
       fos.flush();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:16,代码来源:AbstractQoSTask.java

示例9: test_ConstructorLjava_io_OutputStream

import java.io.FilterOutputStream; //导入方法依赖的package包/类
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());
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:11,代码来源:OldFilterOutputStreamTest.java

示例10: Support_OutputStream

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#write(byte[])
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "write",
    args = {byte[].class}
)
public void test_write$B() throws IOException {
    Support_OutputStream sos = new Support_OutputStream(testLength);
    os = new FilterOutputStream(sos);
    os.write(fileString.getBytes());

    bis = new ByteArrayInputStream(sos.toByteArray());
    assertTrue("Test 1: Bytes have not been written.",
            bis.available() == testLength);
    byte[] wbytes = new byte[testLength];
    bis.read(wbytes, 0, testLength);
    assertTrue("Test 2: Incorrect bytes written or read.",
            fileString.equals(new String(wbytes)));

    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.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:FilterOutputStreamTest.java

示例11: test_close

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#close()
 */
public void test_close() throws IOException {
    bos = new ByteArrayOutputStream();
    os = new FilterOutputStream(bos);
    os.write(fileString.getBytes(), 0, 500);
    os.flush();
    assertEquals("Bytes not written after flush", 500, bos.size());
    os.close();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:FilterOutputStreamTest.java

示例12: test_flush

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#flush()
 */
public void test_flush() throws IOException {
    bos = new ByteArrayOutputStream();
    os = new FilterOutputStream(bos);
    os.write(fileString.getBytes(), 0, 500);
    os.flush();
    assertEquals("Bytes not written after flush", 500, bos.size());
    os.close();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:FilterOutputStreamTest.java

示例13: ByteArrayOutputStream

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#write(byte[])
 */
public void test_write$B() throws IOException {
    bos = new ByteArrayOutputStream();
    os = new FilterOutputStream(bos);
    os.write(fileString.getBytes());
    bis = new ByteArrayInputStream(bos.toByteArray());
    os.flush();
    assertTrue("Bytes not written after flush",
            bis.available() == fileString.length());
    byte[] wbytes = new byte[fileString.length()];
    bis.read(wbytes, 0, fileString.length());
    assertTrue("Incorrect bytes written", fileString.equals(new String(
            wbytes, 0, wbytes.length)));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:FilterOutputStreamTest.java

示例14: test_writeI

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#write(int)
 */
public void test_writeI() throws IOException {
    bos = new ByteArrayOutputStream();
    os = new FilterOutputStream(bos);
    os.write('t');
    bis = new ByteArrayInputStream(bos.toByteArray());
    os.flush();
    assertEquals("Byte not written after flush", 1, bis.available());
    byte[] wbytes = new byte[1];
    bis.read(wbytes, 0, 1);
    assertEquals("Incorrect byte written", 't', wbytes[0]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:FilterOutputStreamTest.java

示例15: test_ConstructorLjava_io_OutputStream

import java.io.FilterOutputStream; //导入方法依赖的package包/类
/**
 * @tests java.io.FilterOutputStream#FilterOutputStream(java.io.OutputStream)
 */
public void test_ConstructorLjava_io_OutputStream() throws IOException {
    bos = new ByteArrayOutputStream();
    os = new FilterOutputStream(bos);
    os.write('t');
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:FilterOutputStreamTest.java


注:本文中的java.io.FilterOutputStream.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。