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

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

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

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

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

  • 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 does not throw an exception at the time of closing the stream.

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

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 PrintWriter
import java.io.*;
public class CloseOfPW {public static void main(String[] args) {String str = "Java Programming";
// Instantiates PrintWriter
PrintWriter p_stm = new PrintWriter(System.out);
// Display str
p_stm.println("str: " + str);
p_stm.flush();
// By using close() method is to
// close the stream p_stm
System.out.println("Stream Shutdown....");
p_stm.close();
}
}

Output

输出量

str: Java Programming
Stream Shutdown....

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

Java PrintWriter 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. 搭建Modelsim SE仿真环境-使用do文件仿真
  2. 第十五周程序阅读-范型程序设计(5)
  3. 003_推箱子-事件
  4. 一只快乐的野指针_野酸枣
  5. C++primer第一章 开始
  6. 宝塔自助建站系统源码v8.0
  7. 日志对于运维的重要性
  8. 随手记_常用coding软件的快捷键-clion/vs code/vs/kdevelop
  9. 【python】ssh密码字典攻击
  10. xdroid on linux 黑屏,常见问题及解决方案
  11. 参加第2届全国高校大数据教学研讨会总结
  12. 日拱一卒,一路向前…… ——我的 CSDN 创作纪念日
  13. pip3 install -U qcloud-python-sts 安装失败解决方法
  14. 根据IP地址查询所在地
  15. C++ 学习记录(18) NVI
  16. Django——09.spaceless, autescape, verbatim标签
  17. 常用的html代码 加粗 加亮 字型加大 变色等
  18. Python 在线免费批量美颜,不比某秀秀方便好用一些吗!
  19. Anaconda安装说明
  20. 微信登陆的LOL只有一个服务器,LOL:新功能!部分大区开放了微信登录功能,网友:有啥用?...

热门文章

  1. nvidia显示设置不可用_Nvidia显示设置不可用,您当前未使用连接到NVIDIA GPU的显示器的解决方法...
  2. c语言删除双向链表重复元素,求一个双向链表的建立,插入删除的c语言程序完整版的,借鉴一下思想,再多说一下就是能运行的那种...
  3. epson彩色打印机加墨水_爱普生打印机墨盒如何加墨?
  4. Python报错:PermissionError: [Errno 13] Permission denied 解决方案详解
  5. Shell 中各种括号的作用
  6. JDK源码解析之java.util.ListIterator
  7. 洛谷P1204 [USACO1.2]挤牛奶Milking Cows 前缀和
  8. 日记 2014-5-18
  9. 自己的利益,还是用户的名义?
  10. 推荐系统相关资源汇总