Simple Algorithm for reading txt files

Source: Internet
Author: User

The netizen asked, reading data from a text file (txt) and making a simple algorithm. The original questions of netizens are as follows,




The netizen's question is that all numbers are numbers, but it does not indicate whether there is only one row. Therefore, Insus. NET algorithm, whether to process text files with multiple lines, whether it is all numbers, whether it is included in a blank line, whether a row has only one number, whether the separator is in front or behind.

Therefore, Insus. NET provides the text file mentioned above as the algorithm object:



OK, Insus. NET prefers to create objects to deal with these problems. Because text files are stored in rows, rows are processed as objects. Logic processing:


Next, Insus. NET writes a number category to process the numbers between each separator (,) in each line.



You also need to create a category to obtain all qualified numbers.



Let's take a look at the result output webpage. Before the output result, we should write a program to read text files, get each line, and process the number of separators in each line. After the List <Number> set is obtained, it is convenient to convert it to int [] arr.



Result:



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.