package com.hspedu.io_; import org.junit.Test; import java.io.FileReader; import java.io.IOException; public class TestFileReader { @Test public void readFile() { String filePath = "e://JavaIO//FileReader//test.txt"; FileReader fileReader = null; int readData = 0; try { fileReader = new FileReader(filePath); while ((readData = fileReader.read()) != -1) { System.out.print((char) readData); } } catch (IOException e) { e.printStackTrace(); } try { fileReader.close(); } catch (IOException e) { e.printStackTrace(); } } }
原创文章,作者:254126420,如若转载,请注明出处:https://blog.ytso.com/244305.html