[英]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.