Tuesday, August 21, 2012

Reading the file content




package com.jsl.io;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class ReadingFileContent {
  public static void main(String[] args) {
    FileInputStream fis=null;
    BufferedInputStream bis=null;

    try {
      fis=new FileInputStream("One.txt");
      bis=new BufferedInputStream(fis);
      int ch;

      while((ch=bis.read())!=-1){
         System.out.print((char)ch);
      }
    } catch (Exception e) { 
       e.printStackTrace();
    }finally{
         try {
            bis.close();
            fis.close();
         } catch (IOException e) {
            e.printStackTrace();
         }
    }
  }
}

No comments:

Post a Comment

Spring Boot 3 : JWT with SecurityFilterChain, AuthorizeHttpRequests, RequestMatchers

pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"...