Mega Code Archive

 
Categories / Java Tutorial / File
 

Constructing FileInputStream to read from a Text File

import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.nio.channels.FileChannel; public class MainClass {   public static void main(String[] a) {     File aFile = new File("charData.txt");     FileInputStream inFile = null;     try {       inFile = new FileInputStream(aFile);     } catch (FileNotFoundException e) {       e.printStackTrace(System.err);       System.exit(1);     }     FileChannel inChannel = inFile.getChannel();   } }