- SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks Interfaces Interfaces

shape Introduction Interfaces - The data steaming, serialization and the file system for a system is provided by


shape Table Interfaces Description
FileFilter Abstract pathnames can be known using this interface.
FilenameFilter This interface is used to filter the filenames of a particular class.
Data Input Used to reconstruct the data and read the bytes from the binary stream in a java primitive types.
Data Output This interface used to convert the data of a java primitive type to a series of bytes and write to a binary stream.
Closeable The destination or source of a data can be closed using this interface.
Externalizable This interface used to identify a class of Externalizable instance and responsible for saving and restoring contents of a class, which are written in the serialization stream.
Flushable The data can be flushed using this interface.
Object Input Using this interface the data input can be extended and the objects can be read.
Object Output This interface used to extend the data output interface, which include writing of objects.
ObjectInputValidation This interface is used to callback and allow the validations of object in a graph.
ObjectStreamConstants By using this interface the constants can be written into the object serialization stream.
Serializable By implementing the interface, this interface enables.

shape Example Interfaces - The following is an example. [java] package; import; import; import; import; import; public class DataInputStreamDemo { public static void main(String[] args) throws IOException { InputStream is = null; DataInputStream dis = null; try{ // create input stream from file input stream is = new FileInputStream("E:\\splesson.txt"); // create data input stream dis = new DataInputStream(is); // count the available bytes form the input stream int count = is.available(); // create buffer byte[] bs = new byte[count]; // read data into buffer; // for each byte in the buffer for (byte b:bs) { // convert byte into character char c = (char)b; // print the character System.out.print(c+" "); } }catch(Exception e){ // if any I/O error occurs e.printStackTrace(); }finally{ // releases any associated system files with this stream if(is!=null) is.close(); if(dis!=null) dis.close(); } } } [/java] Output The following is the result. [java]H e l l o J a v a . J a v a I O i s f u n . [/java]


shape Key Points

  • Interfaces - The data steaming, serialization and the file system for a system is provided by