IT. Expert System.

Java basics

mark()


The java.io.InputStream.mark(int readlimit) method marks the current position in this input stream. A subsequent invocation to the reset() method reposition the stream to the recently marked position.

Syntax:
public void mark(int readlimit)


Example:

import java.io.FileInputStream;
import java.io.InputStream;

public class InputStreamDemo {
   public static void main(String[] args) throws Exception {
      InputStream is = null;
            
      try{
         // new input stream created
         is = new FileInputStream("C://test.txt");
         
         // read and print characters one by one
         System.out.println("Char : "+(char)is.read());
         System.out.println("Char : "+(char)is.read());
         System.out.println("Char : "+(char)is.read());
                     
         // mark is set on the input stream
         is.mark(0);
         
         System.out.println("Char : "+(char)is.read());
         System.out.println("Char : "+(char)is.read());
         
         if(is.markSupported())
         {
            // reset invoked if mark() is supported
            is.reset();
            System.out.println("Char : "+(char)is.read());
            System.out.println("Char : "+(char)is.read());
         }
         
      }catch(Exception e){
         
         // if any I/O error occurs
         e.printStackTrace();
      }finally{
         
         // releases system resources associated with this stream
         if(is!=null)
            is.close();
      }
   }
}


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 431 / 158766329. Delta: 4.08451 с