Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
JAVA.IO.FILEINPUTSTREAM.SKIP METHOD http://www.tutorialspoint.com/java/io/fileinputstream_skip.htm Copyright © tutorialspoint.com Description The java.io.FileInputStream.skiplongn skips over and discards n bytes of data from the input stream. Declaration Following is the declaration for java.io.FileInputStream.skiplongn method: public long skip(long n) Parameters n - the number of bytes to be skipped. Return Value The method returns the actual number of bytes skipped. Exception IOException - If an I/O error occurs, if n is negative or if the stream does not support seek. Example The following example shows the usage of java.io.FileInputStream.skiplongn method. package com.tutorialspoint; 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(); } } } Assuming we have a text file c:/test.txt, which has the following content. This file will be used as an input for our example program: ABCDEF Let us compile and run the above program, this will produce the following result: Character read: E Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js