Source Code : Read file character by character

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Read file character by character

   

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Main {
  public static void main(String[] args) {
    File file = new File(args[0]);
    if (!file.exists()) {
      System.out.println(args[0] + " does not exist.");
      return;
    }
    if (!(file.isFile() && file.canRead())) {
      System.out.println(file.getName() + " cannot be read from.");
      return;
    }
    try {
      FileInputStream fis = new FileInputStream(file);
      char current;
      while (fis.available() > 0) {
        current = (char) fis.read();
        System.out.print(current);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}

   
    
    
  

Thank with us