2:25 am - Tuesday March 28, 2017

BufferedInputStream 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
/**
 program : BufferedInputStream example program for skip(long n) in java
 author  : "candid"
 date    : 21.11.12
 */
//java code
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Skip1 {
	public static void main(String[] args) throws Exception {
		InputStream is = null;
		FilterInputStream fis = null;
		int i = 0;
		char c;
		try {
			is = new FileInputStream("F:/karthi/BIStreamSkip/karthi.txt");// karthi.txt
			// content:karthi
			fis = new BufferedInputStream(is);
			while ((i = fis.read()) != -1) {
				c = (char) i;
				fis.skip(3);
				System.out.println("Character read: " + c);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (is != null)
				is.close();
			if (fis != null)
				fis.close();
		}

	}
}

Output

Character read: k
Character read: h

BACK

Filed in: Z-A All Java Codes

Comments are closed.