3:45 pm - Sunday June 25, 2017

FileInputStream example program for skip(long n) in java

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
 *@author: candidjava
 *@description:
 **/
import java.io.IOException;
import java.io.FileInputStream;

public class FileInputStreamDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = null;
        int i = 0;
        char c;
        try {
            // create new file input stream
            fis = new FileInputStream("C://test.txt");
            // skip bytes from file input stream
            fis.skip(4);
            // read bytes from this stream
            i = fis.read();
            // converts integer to character
            c = (char) i;
            // prints
            System.out.print("Character read: " + c);
        } catch (Exception ex) {
            // if any error occurs
            ex.printStackTrace();
        } finally {
            // releases all system resources from the streams
            if (fis != null)
                fis.close();
        }
    }
}

Output

Character read: E

BACK

Filed in: Z-A All Java Codes

Comments are closed.