简体   繁体   English

从文本文件读取

[英]reading from text file

I'm writing a program which reads only integers from a text file. 我正在编写一个仅从文本文件中读取整数的程序。 I have done the lions share of the program, however one thing is bothering me 我已经完成了程序的大部分任务,但是一件事困扰着我

When a non integer is in the text file, all the correct integers should be printed, with element not valid, replacing the element which is not valid. 当文本文件中有非整数时,应打印所有正确的整数,且元素无效,替换无效的元素。 For example 10, 203, 2.02 10 would print 10, 203, element not valid 10 . 例如10、203、2.02 10将打印10、203,元素无效10。 For this do i use an array to access the part which is not valid? 为此,我是否使用数组来访问无效的部分?

Any suggestions? 有什么建议么?

If number of arguments is 2, here is how would you do it : 如果参数个数为2,则如何操作:

public static void main(String[] args) {
        if (args.length != 2) {
            System.err.println("Usage: ...");
        }
    }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM