Java LineNumberInputStream reset()方法与示例_cumtv80668的博客-程序员秘密

技术标签: spring  jvm  python  java  编程语言  

LineNumberInputStream类reset()方法 (LineNumberInputStream Class reset() method)

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

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

  • reset() method is used to reset this LineNumberInputStream and it reset the stream to the position of the most recent mark() was set on this stream.

    reset()方法用于重置此LineNumberInputStream,并将该流重置为对此流设置的最新mark()的位置。

  • reset() 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.

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

  • reset() method may throw an exception at the time of resetting the stream.

    reset()方法在重置流时可能会引发异常。

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

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

Syntax:

句法:

    public void reset();

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 mark(int r_limit) method of 
// LineNumberInputStream

import java.io.*;

public class MarkOfLNIS {
    
 public static void main(String[] args) throws Exception {
    
  FileInputStream fis_stm = null;
  LineNumberInputStream line_stm = null;
  int val = 0;

  try {
    
   // Instantiates FileInputStream
   fis_stm = new FileInputStream("D:\\includehelp.txt");
   line_stm = new LineNumberInputStream(fis_stm);

   // By using read() method isto 
   // read the character from line_stm
   char ch1 = (char) line_stm.read();
   char ch2 = (char) line_stm.read();
   char ch3 = (char) line_stm.read();

   System.out.println("ch1: " + ch1);
   System.out.println("ch2: " + ch2);
   System.out.println("ch3: " + ch3);

   // By using mark() method isto
   // set the current position in this
   // line_stm

   System.out.println("line_stm.mark(0): ");
   line_stm.mark(0);
   char ch4 = (char) line_stm.read();
   char ch5 = (char) line_stm.read();

   System.out.println("ch4: " + ch4);
   System.out.println("ch5: " + ch5);
   // By using reset() method isto
   // reset the stream to the position 
   // set by the call mark() method

   System.out.println("line_stm.reset(): ");
   line_stm.reset();
   char ch6 = (char) line_stm.read();
   char ch7 = (char) line_stm.read();
   char ch8 = (char) line_stm.read();
   char ch9 = (char) line_stm.read();


   System.out.println("ch4: " + ch6);
   System.out.println("ch5: " + ch7);
   System.out.println("ch6: " + ch8);
   System.out.println("ch7: " + ch9);

  } catch (Exception ex) {
    
   System.out.println(ex.toString());
  } finally {
    
   // with the help of this block is to
   // free all necessary resources linked
   // with the stream
   if (fis_stm != null) {
    
    fis_stm.close();
    if (line_stm != null) {
    
     line_stm.close();
    }
   }
  }
 }
}

Output

输出量

ch1: J
ch2: A
ch3: V
line_stm.mark(0):
ch4: A
ch5: W
line_stm.reset(): Reset Not Supported


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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/cumtv80668/article/details/107800050

智能推荐

微信公众号盈利模式_微信公众号的盈利方式有哪些?_半木zxy的博客-程序员秘密

微信公众号的盈利方式有哪些?我觉得大概也就两方面吧,第一个人就是你把你微信公众号的阅读量啊,粉丝量啊,做的非常大啊,非常高,然后你可以接一些商业性的广告就是,嗯,投放广告的盈利。其次就是你也可以自己去卖货呀,这是付费也可以啊,你开麦一些实体的产品,为你的电商平台压货什么的,你去倒流啊,通过流量的变现,但是他们前提都是一个,就是你得有粉丝了啊,你得有真正的用户数。但是说真的,就今天这个节点啊,到了2...

箭头函数与普通函数的区别_promise箭头和非箭头函数的区别_Jessie.Zhai的博客-程序员秘密

1、箭头函数是匿名函数,不能作为构造函数,不能使用newlet FunConstructor=()=>{ console.log(1111)}let fc=new FunConstructor();//Uncaught TypeError:FunConstructor is not a constructor at <anonymous>:1:102、箭头函数不能绑定arguments,取而代之用rest参数…解决 function Argu(a){ con

关于Tomcat服务器的一些注意问题_tomcat作为服务器需要注意什么_DayFight_DayUp的博客-程序员秘密

1软件的结构C/S (Client - Server 客户端-服务器端) 典型应用:QQ软件 ,飞秋,红蜘蛛。 特点: 1)必须下载特定的客户端程序。 2)服务器端升级,客户端升级。B/S (Broswer -Server 浏览器端- 服务器端) 典型应用: 腾讯官方(www.qq.com) 163新闻网站, 传智官网(俗称:网站) 特点: 1)不需要安装特定的客户端(只需要安装浏

不同python版本pip安装出现问题:whl is not a supported wheel on this platfrom_pycharm按照库 is not a supported wheel on this platfr_JD_Wang0的博客-程序员秘密

pip指令对应不同python版本**问题:**安装pytlp出现whl is not a supported wheel on this platfrom,所需python版本为3.6,但我安装的python版本为3.7。**原因:**不同版本python所对应pip不同,在power shell运行pip时,运行了python3.7的pip,因此不匹配。**解决方案:**调整环境变量顺序,将python3.6的path放置在python3.7之前,则运行pip时优先运行python3.6的p

APM_ArduCopter源码解析学习(五)——GPS_rtcm3数据_zhangfengmei1987的博客-程序员秘密

文章目录 目录前言1.GPS信息简介1. GPGGA(gps定位信息)2. GPGSA(当前卫星信息)3. GPGSV(可见卫星信息)4. GPRMC (推荐定位信息)5. GPVTG (地面速度信息)6. GPG LL(定位地理信息)7. GPZDA (当前时间信息)8.GPS的UBLOX协议 2.GPS传感器初始化1.执行 GPS的串口协议初始化:serial_manager.init();2.GPS函数初始化 3.更新GPS数据1. gps.update();1.update_inst...

jQuery实现小功能之弹出层_jquery.pop.js_BunnyMelody的博客-程序员秘密

自定义插件实现弹出层 【jqueryPopIndex.html】<!DOCTYPE html><html> <head> <meta charset="utf-8"/> <link rel="stylesheet" href="jqueryPop.css"> <title>jquery 实现弹出层</title> <sc

随便推点

Android Universal Image Loader 源码分析_VK2016的博客-程序员秘密

1. 功能介绍1.1 Android Universal Image LoaderAndroid Universal Image Loader 是一个强大的、可高度定制的图片缓存,本文简称为UIL。简单的说 UIL 就做了一件事——获取图片并显示在相应的控件上。1.2 基本使用1.2.1 初始化添加完依赖后在Application或Activity中初始

怎么监控Linux系统的内存使用_linux监控进程占用内存_富甲一方张三的博客-程序员秘密

了解系统的RAM使用量是有几个好处的。首先,它可以让你了解是否有必要升级服务器或者计算机的内存量。如果你看到内存使用率经常接近满容量,它可能表明你的系统需要升级。另一方面,他还可以帮助你跟踪系统上的问题。内存使用量的激增可能表明计算机上运行的进程有问题。在这篇针对Linux管理员的教程中,我们将介绍一些检查和监控Linux上RAM使用情况的方法。在这个教程你将要学习:使用free命令检查内存用量使用free命令持续监控内存用量free命令是怎么工作的?使用top命令检查内存用量使用htop命

剑指 Offer 18. 删除链表的节点——变一个头结点出来_Chaim16的博客-程序员秘密

原题链接题目描述给定单向链表的头指针和一个要删除的节点的值,定义一个函数删除该节点。返回删除后的链表的头节点。注意:此题对比原题有改动示例 1输入: head = [4,5,1,9], val = 5输出: [4,1,9]解释: 给定你链表中值为 5 的第二个节点,那么在调用了你的函数之后,该链表应变为 4 -&gt; 1 -&gt; 9.示例 2输入: head = [4,5,1,9], val = 1输出: [4,5,9]解释: 给定你链表中值为 1 的第三个节点,那么在调用了你

ajax 实现文件上传/下载_ajax 上传_码农小白007的博客-程序员秘密

文件上传&amp;lt;!DOCTYPE html&amp;gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt; &amp;lt;title&amp;gt;XMLHttpRequest上传文件进度实现&amp;lt;/title&amp;gt; &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;

iModel 模型驱动软件开发平台 -开启信息管理软件DIY之旅(转)_imodel 模型引擎_wsimei的博客-程序员秘密

一,    软件开发历史、现状和探索。 自从有了计算机,人类的工作就变的轻松了,生活就变的丰富多彩了,这种神奇的机器在各行各业中发挥着巨大的作用,计算机极大的扩展了人类大脑的能力,甚至可以说计算机的出现加速了人类社会的发展进程。 计算机之所以不同与一般的机械设备,就是因为它有“灵魂”的,如果说硬件是计算机“身体”,而控制计算机的软件就是计算机的“灵魂”。 软件是在为了满足工作和生活需求而模拟现实世

忘记mysql数据库密码后的修改密码方式_zhaixing_0307的博客-程序员秘密

当忘记mysql数据库密码如何进行密码修改(本文mysql版本为5.7)1.进入mysql配置文件中[[email protected] ~]# vim /etc/my.cnf2.在[mysqld]中添加 skip-grant-tables(跳过数据权限验证)[mysqld]skip-grant-tables3.重启数据库,让配置文件生效[[email protected] ~]# systemctl restart mysqld4.登录数据库因为前面在配置文件中加入了跳过验证,所以这里不用输入