Java implementation reads the contents of TXT file

Let's start with an example

After reading the above example, let's study it in detail

Java reads the contents of TXT file. It can be understood as follows:

First get a file handle. File file = new File(); File is the file handle. The two are connected to the telephone network. Then you can start making phone calls.

Read Party A's information through this line: new FileInputStream (file). At present, this information has been read into the memory. Next, it needs to be interpreted as something that Party B can understand

Now that you use fileinputstream(). The corresponding needs to use the inputstreamreader () method to interpret the data just loaded into the memory

Output it after interpretation. Of course, it should be converted into data that IO can recognize. Then you need to call the method BufferedReader () for bytecode reading. At the same time, use the readLine () method of BufferedReader () to read each line of data in the txt file.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>