Java PipedInputStream close()方法与示例
PipedInputStream类close()方法 (PipedInputStream Class close() method)
close() method is available in java.io package.
close()方法在java.io包中可用。
close() method is used to close this PipedInputStream and free all system resources linked with this stream.
close()方法用于关闭此PipedInputStream并释放与此流链接的所有系统资源。
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 PipedInputStream
import java.io.*;
public class CloseOfPIS {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();
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++;
}
// By using close() method is to close
// the stream
pipe_in.close();
pipe_out.close();
// when we call read() after closing the stream
// will result an exception
for (int i = 0; i < 3; ++i) {// By using read() method is to
// read the integer and convert it into
// char
char ch = (char) pipe_in.read();
System.out.println("pipe_in.read(): " + ch);
}
} catch (Exception ex) {System.out.println("Stream Closed Before!!!!");
}
}
}
Output
输出量
Stream Closed Before!!!!
翻译自: https://www.includehelp.com/java/pipedinputstream-close-method-with-example.aspx
Java PipedInputStream close()方法与示例相关推荐
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- java receive_Java PipedInputStream receive()方法与示例
PipedInputStream类receive()方法receive()方法在java.io包中可用. receive()方法用于接收内容的一个字节,当不再有剩余输入时它将阻塞. receive() ...
- java user directory,Java ProcessBuilder directory()方法与示例
语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...
- Java序列化魔术方法及其示例使用
在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...
- catalog java,Java Connection getCatalog()方法与示例
通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...
- filepermission java,Java FilePermission getActions()方法与示例
FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...
- java方法参数Bundle,Java ResourceBundle keySet()方法及示例
ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...
- java exec waitfor,Java Process waitFor()方法与示例
流程类waitFor()方法在java.lang包中提供了waitFor()方法. waitFor()方法用于使当前正在运行的线程在需要时等待,直到由该Process对象表示的进程完成其终止为止. 当 ...
- java arraylist.add(),Java ArrayList add()方法与示例
ArrayList类add()方法 语法:public boolean add(T ele); public void add(int indices, T ele);add()方法在java.uti ...
- java rollback用法,Java Connection rollBack()方法与示例
回滚操作将撤消当前事务所做的所有更改,即,如果调用Connection接口的rollBack()方法,则所有修改都将还原到最后一次提交. 您还可以通过将所需的Savepoint对象作为参数传递给此方法 ...
最新文章
- Tensorflow |(1)初识Tensorflow
- linux两个文件修改主机名
- 动态规划-换钱最少货币数
- matlab激光散斑散射半径测量,激光散斑测量2011412225741
- C语言试题六之使字符串的前导*号不得多于n个;若多于n个,则删除多于的*号;若少于或等于n个,则什么也不做。字符串中间和尾部的*号不删除。
- 数据库迁移mysql到sqlserver_数据库迁移(sqlserver至mysql)
- Bootstrap 4:如何使顶部固定的Navbar保持在容器中而不拉伸?
- 泰山行宫碧霞元君祠_临清市泰山行宫碧霞元君祠5月4号(农历三月三十日)举行大型泰山奶奶接驾法会...
- 计算机应用基础形考作业3Excel部分,计算机应用基础形考3,Excel部分
- 7.2Python入门(三)
- android真实项目教程(二)——漫画App初构_by_CJJ
- 控制反转和依赖注入的理解(通俗易懂)_Spring 的本质系列之依赖注入_一点课堂(多岸学院)...
- Python3.6 安装pandas包的方法
- 十分钟教你学会vi编辑器使用方法(详细版)
- matlab求矩阵 均值、标准差、最大值以及reshape()函数
- LPDDR4 layout instruction
- 【Java 8 新特性】Java CompletableFuture thenApply()
- 算法导论为何被称为CLRS
- sencha touch 百度地图扩展(2014-6-24)(废弃 仅参考)
- 学历焦虑正在摧毁新一代测试工程师!学历不够如何破局?
热门文章
- java存储键值结构_java-键值存储为主数据库
- ?php php,PHP: Balises PHP - Manual
- 关于mmdetection上手的几点说明
- oracle 结果集已耗尽_java.sql.SQLException: 结果集已耗尽
- python图像识别代码_用Python进行简单图像识别(验证码)
- python virtualenv conda_在vscode中启动conda虚拟环境的思路详解
- c中获取python控制台输出_在真实的tim中用C捕获控制台python打印
- 计算机护理职称考试报名时间2015,护理职称考试怎么报名?
- ubunt16.04 安装3090显卡驱动 cuda cudnn pytorch
- Nginx主配置文件nginx.conf中文详解