Java examples for File Path IO:FileInputStream
Read a text block by block using InputStream and FileInputStream
import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class InputStreamTest { public static void main(String[] args) throws IOException{ InputStream inputStream = null; try{// w w w . jav a 2s. c o m inputStream = new FileInputStream("C:/input.txt"); byte[] bytes = new byte[1024]; int index; while((index = inputStream.read(bytes)) != -1){ System.out.println("index ="+index); } }finally{ if(inputStream != null){ inputStream.close(); } } } }