PipedOutputStream类close()方法 (PipedOutputStream Class close() method)

  • close() method is available in java.io package.

    close()方法在java.io包中可用。

  • close() method is used to close this PipedOutputStream and free all system resources linked with this stream.

    close()方法用于关闭此PipedOutputStream并释放与此流链接的所有系统资源。

  • close() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    close()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • close() method may throw an exception at the time of closing the stream.

    close()方法在关闭流时可能会引发异常。

    IOException: This exception may throw when getting any input/output error while performing.

    IOException :在执行过程中遇到任何输入/输出错误时,可能引发此异常。

Syntax:

句法:

    public void close();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is void, it returns nothing.

该方法的返回类型为void ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example
// of void close() method of PipedOutputStream
import java.io.*;
public class CloseOfPOS {public static void main(String[] args) throws Exception {int val = 65;
try {// Instantiates PipedInputStream and
// PipedOutputStream
PipedInputStream pipe_in = new PipedInputStream();
PipedOutputStream pipe_out = new PipedOutputStream();
// By using close() method is to close
// the stream
pipe_in.close();
pipe_out.close();
// when we call write() method after closing the
// stream will result an exception
for (int i = 0; i < 3; ++i) {// By using write() method is to
// write the val to the stream pipe_out
pipe_out.write(val);
val++;
}
} catch (Exception ex) {System.out.println("Stream Closed Before!!!!");
}
}
}

Output

输出量

Stream Closed Before!!!!

翻译自: https://www.includehelp.com/java/pipedoutputstream-close-method-with-example.aspx

Java PipedOutputStream close()方法与示例相关推荐

  1. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  2. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  3. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  4. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  5. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  6. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

  7. java exec waitfor,Java Process waitFor()方法与示例

    流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...

  8. java arraylist.add(),Java ArrayList add()方法与示例

    ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...

  9. java rollback用法,Java Connection rollBack()方法与示例

    回滚操作将撤消当前事务所做的所有更改,即,如果调用Connection接口的rollBack()方法,则所有修改都将还原到最后一次提交. 您还可以通过将所需的Savepoint对象作为参数传递给此方法 ...

  10. inputstream 关闭 java,Java ObjectInputStream close()方法与示例

    ObjectInputStream类close()方法close()方法在java.io包中可用. close()方法用于关闭此ObjectInputStream并释放与此流链接的所有系统资源. cl ...

最新文章

  1. 052_Unicode字符官方标准三
  2. VTK:可视化之Hawaii
  3. 大剑无锋之post那么多优点,为什么还用get
  4. 代理模式(多线程实现状态监控)
  5. 字符缓冲输入流,高效读取整行数据
  6. mysql select语句执行顺序
  7. C#:JObject、JArray、JProperty、JValue作用
  8. pve万兆网卡驱动_无线环境下打游戏,还能不能更稳?附各类AX网卡换装思路
  9. Java面试面经大合集(含答案),大厂越来越简单进了,建议收藏
  10. LVDS通信协议以及概念
  11. axure 侧滑抽屉式菜单_Axure教程之抽屉菜单
  12. 美团大众点评2017校园招聘笔试(编程题)
  13. oracle公司的crm有哪些主要模块,Oracle CRM 的组成及各模块的功能
  14. loadrunner11 录制手机
  15. Hadoop单词统计实验
  16. MATLAB如何读取文件中的数据(全网最简便)
  17. 【交往智慧】004.己所不欲,勿施于人
  18. 嵌入式Linux根文件系统制作
  19. linux端口带卡,基于嵌入式Linux的接口转换卡设计
  20. 学习app.config连接数据库的配置

热门文章

  1. 软件测试项目时间一般多少钱,项目的时间进度该如何估算?
  2. mysql 123456_MySQL字符串中抽取数值的方法 select -(-'123456@163.com'); 很牛逼
  3. 商场楼层导视牌图片_百宝图商场电子导视软件中预约产品功能简介
  4. wxpython多线程 假死_wxpython中利用线程防止假死的实现方法
  5. mysql通过集合查询_MySQL使用集合函数进行查询操作实例详解
  6. 依赖 netty spring_十分钟带你了解Spring的七大知识点,程序员必了解
  7. 和python哪个容易胖_为什么有些人特别容易胖?
  8. UVA - 512 ​​​​​​​Spreadsheet Tracking
  9. Day31 python基础--网络编程基础-socketserver
  10. ARC和MRC 兼容的单例模式