Scanner vs. BufferedReader

前端 未结 12 1773
死守一世寂寞
死守一世寂寞 2020-11-22 02:17

As far I know, the two most common methods of reading character-based data from a file in Java is using Scanner or BufferedReader. I also know that

12条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 02:56

    1. BufferedReader will probably give you better performance (because Scanner is based on InputStreamReader, look sources). ups, for reading from files it uses nio. When I tested nio performance against BufferedReader performance for big files nio shows a bit better performance.
    2. For reading from file try Apache Commons IO.

提交回复
热议问题