The shortest path to open a file in Java using encoding and readline()?

What is the shortest way to open a file and set its encoding using the readLine () method?

Is the downlink correct and shortest?

BufferedReader reader = 
    new BufferedReader(
         new InputStreamReader(
             new FileInputStream(myPath),myEncoding));

Solution

Using scanner, you can do the following: scanner scan = new scanner (new file (mypath), myencoding), and then scan the returned string nextLine().

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
分享
二维码
< <上一篇
下一篇>>