當前位置: 首頁>>代碼示例>>Java>>正文


Java FilterOutputStream.flush方法代碼示例

本文整理匯總了Java中java.io.FilterOutputStream.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java FilterOutputStream.flush方法的具體用法?Java FilterOutputStream.flush怎麽用?Java FilterOutputStream.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.FilterOutputStream的用法示例。


在下文中一共展示了FilterOutputStream.flush方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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


注:本文中的java.io.FilterOutputStream.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。