Java LineNumberReader getLineNumber()方法及示例
LineNumberReader类的getLineNumber()方法 (LineNumberReader Class getLineNumber() method)
getLineNumber() method is available in java.io package.
getLineNumber()方法在java.io包中可用。
getLineNumber() method is used to return the present line number in this LineNumberReader stream.
getLineNumber()方法用于返回此LineNumberReader流中的当前行号。
getLineNumber() 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.
getLineNumber()方法是一个非静态方法,只能使用类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
getLineNumber() method does not throw an exception at the time of returning the current line number.
getLineNumber()方法在返回当前行号时不会引发异常。
Syntax:
句法:
public int getLineNumber();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of the method is int, it returns the present line number from this LineNumberReader.
方法的返回类型为int ,它从此LineNumberReader返回当前行号。
Example:
例:
// Java program to demonstrate the example
// of int getLineNumber() method of
// LineNumberReader
import java.io.*;
public class GetLineNumberOfLNR {public static void main(String[] args) throws Exception {FileReader fr_stm = null;
LineNumberReader line_r = null;
int val = 0;
try {// Instantiates FileReader and LineNumberReader
fr_stm = new FileReader("D:\\includehelp.txt");
line_r = new LineNumberReader(fr_stm);
// By using getLineNumber() method is to
// return the current line number in this
// stream line_r
int line_num = line_r.getLineNumber();
System.out.println("line_r.getLineNumber(): " + line_num);
} 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 (fr_stm != null) {fr_stm.close();
if (line_r != null) {line_r.close();
}
}
}
}
}
Output
输出量
line_r.getLineNumber(): 0
翻译自: https://www.includehelp.com/java/linenumberreader-getlinenumber-method-with-example.aspx
Java LineNumberReader getLineNumber()方法及示例相关推荐
- Java IOUtils.copy方法代码示例(亲测)
本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...
- 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对象作为参数传递给此方法 ...
最新文章
- 20行Python代码给微信头像戴帽子
- 洛谷P1832 A+B Problem(再升级)
- python文件引用其他文件中的变量
- 基于vue的移动web app页面缓存解决方案
- Convolutional Neural Networks for Sentence Classification
- 理性预期学派(Rational Expectation School)
- DCMTK:TLS测试DcmSCP和DcmSCPPool类
- redis复制原理和应用
- Linux 系统的IP与域名解析文件[局域网的DNS]
- ISA2000资料大全(详细)
- IT基础架构规划方案一(网络系统规划)
- Vue Router 重定向和别名
- UNI-APP前后端实战课《悦读》
- Social Recommendation with Strong and Weak Ties 学习笔记
- 【深度学习】注意力机制
- 教你如何编写游戏外挂
- 3分钟弄明白顶级域名二级域名子域名父域名的区别
- 黑磷量子点/无机荧光量子点/石墨烯量子点水凝胶/量子点/纳米水凝胶荧光探针的研究制备
- Truck History prime
- 百度智能手环方案开源(含源码,原理图,APP,通信协议等)...