简体   繁体   English

如何读取文本文件中每行的最后一位数字?

[英]How to read the last digit of each line in a text file?

I am making a program that reads data in text files.我正在制作一个读取文本文件中数据的程序。 I also need to know the last number of each line in that file.我还需要知道该文件中每一行的最后一个数字。 I was wondering if there is a simply way of doing this.我想知道是否有一种简单的方法可以做到这一点。

text file example:文本文件示例:

Name: Bob DOB: 1995-04-11 ID: 1姓名:鲍勃 出生日期:1995-04-11 ID: 1

Name: Bill DOB: 1992-07-12 ID: 2姓名:比尔 出生日期:1992-07-12 ID: 2

尝试使用以下一种衬垫:

Files.lines(path).forEach(s -> System.out.println(s.charAt(s.length() - 1)));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何读取文件并按行拆分文本? - How to read a file and split the text by each line? 如何读取文本文件中除最后一行以外的全部文本? - How to read whole the text in text file except last line? 如何从最后一行读取文本文件 - How to read a text file from the last line to the first 快速阅读文本文件的最后一行? - Quickly read the last line of a text file? 如何读取将读取包含文本的文件。 读取每一行并将其发送到输出文件,并在其前加上行号 - How to read reads a file containing text. Read each line and send it to the output file, preceded by line numbers Java:如何读取文本文件的每一行并将每一行设置为数组元素? - Java: How do you read each line of a text file and setting each line as an array element? 如何在Java中一行一行地读取文本文件,并分别分隔每一行的内容? - How do you read a text file, line by line, and separate contents of each line in Java? 如何从文本文件中读取前三个三位数字? - How to read the first 3 three-digit numbers from a text file? 哪个是读取Java中文本文件最后一行的最佳方法? - Which is the best way to read the last line of a text file in Java? 如何在每行Java上读取带有数字的文件 - How to read a file with a number on each line java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM