Menu Bar

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label Java IO Tutorial. Show all posts
Showing posts with label Java IO Tutorial. Show all posts

Friday, 19 May 2017

What is PipedInputStream Class In Java ?

Class PipedInputStream

All Implemented Interfaces:
Closeable, AutoCloseable

Declaration of PipedInputStream:
public class PipedInputStream
extends InputStream

A pipedinputstream should be connected to a piped output stream; the piped input stream then provides whatever data bytes are written to the piped output stream. 

Typically, data is read from a PipedInputStream object by one thread and data is written to the corresponding PipedOutputStream by some other thread. 

Attempting to use both objects from a single thread is not recommended, as it may deadlock the thread. The piped input stream contains a buffer, decoupling read operations from write operations, within limits. A pipe is said to be broken if a thread that was providing data bytes to the connected piped output stream is no longer alive.

Constructor Summary of PipedInputStream :

Constructor
Description
PipedInputStream()
Creates a PipedInputStream so that it is not yet connected.
PipedInputStream(int pipeSize)
Creates a PipedInputStream so that it is not yet connected and uses the specified pipe size for the pipe's buffer.
PipedInputStream(PipedOutputStream src)
Creates a PipedInputStream so that it is connected to the piped output stream src.
PipedInputStream(PipedOutputStream src, int pipeSize)
Creates a PipedInputStream so that it is connected to the piped output stream src and uses the specified pipe size for the pipe's buffer.

Method Summary of PipedInputStream :

Modifier
Method Name
Description
int
available()
Returns the number of bytes that can be read from this input stream without blocking.
void
close()
Closes this piped input stream and releases any system resources associated with the stream.
void
connect(PipedOutputStream src)
Causes this piped input stream to be connected to the piped output stream src.
int
read()
Reads the next byte of data from this piped input stream.
int
read(byte[] b, int off, int len)
Reads up to len bytes of data from this piped input stream into an array of bytes.
protected void
receive(int b)
Receives a byte of data.


      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

Read More »

Thursday, 18 May 2017

What is ObjectInputStream Class In Java ?

Class ObjectInputStream

All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable

Declaration of ObjectInputStream:
public class ObjectInputStream
extends InputStream
implements ObjectInput, ObjectStreamConstants

ObjectInputStream class (java.io.ObjectInputStream) enables you to read Java objects from an InputStream . We wrap an InputStream in a ObjectInputStream and then you can read objects from it. Implementing the Serializable interface allows object serialization to save and restore the entire state of the object.

Normally you will use the ObjectInputStream to read objects written (serialized) by a Java ObjectOutputStream .

Only objects that support the java.io.Serializable or java.io.Externalizable interface can be read from streams.

The method readObject is used to read an object from the stream. Java's safe casting should be used to get the desired type. 

The default deserialization mechanism for objects restores the contents of each field to the value and type it had when it was written. 

Fields declared as transient or static are ignored by the deserialization process.

Constructor Summary of ObjectInputStream:

Constructor
Description
ObjectInputStream()
Provide a way for subclasses that are completely reimplementing ObjectInputStream to not have to allocate private data just used by this implementation of ObjectInputStream.
ObjectInputStream(InputStream in)
Creates an ObjectInputStream that reads from the specified InputStream.

Method Summary of ObjectInputStream:

Modifier
Method Name
Description
int
available()
Returns the number of bytes that can be read without blocking.
void
close()
Closes the input stream.
void
defaultReadObject()
Read the non-static and non-transient fields of the current class from this stream.
protected Boolean
enableResolveObject(boolean enable)
Enable the stream to allow objects read from the stream to be replaced.
int
read()
Reads a byte of data.
int
read(byte[] buf, int off, int len)
Reads into an array of bytes.
boolean
readBoolean()
Reads in a boolean.
byte
readByte()
Reads an 8 bit byte.
char
readChar()
Reads a 16 bit char.
protected ObjectStreamClass
readClassDescriptor()
Read a class descriptor from the serialization stream.
double
readDouble()
Reads a 64 bit double.
ObjectInputStream.GetField
readFields()
Reads the persistent fields from the stream and makes them available by name.
float
readFloat()
Reads a 32 bit float.
void
readFully(byte[] buf)
Reads bytes, blocking until all bytes are read.
void
readFully(byte[] buf, int off, int len)
Reads bytes, blocking until all bytes are read.
int
readInt()
Reads a 32 bit int.
String
readLine()
Deprecated.
This method does not properly convert bytes to characters. see DataInputStream for the details and alternatives.
long
readLong()
Reads a 64 bit long.
Object
readObject()
Read an object from the ObjectInputStream.
protected Object
readObjectOverride()
This method is called by trusted subclasses of ObjectOutputStream that constructed ObjectOutputStream using the protected no-arg constructor.
short
readShort()
Reads a 16 bit short.
protected void
readStreamHeader()
The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers.
Object
readUnshared()
Reads an "unshared" object from the ObjectInputStream.
int
readUnsignedByte()
Reads an unsigned 8 bit byte.
int
readUnsignedShort()
Reads an unsigned 16 bit short.
String
readUTF()
Reads a String in modified UTF-8 format.
void
registerValidation(ObjectInputValidation obj, int prio)
Register an object to be validated before the graph is returned.
protected Class<?>
resolveClass(ObjectStreamClass desc)
Load the local class equivalent of the specified stream class description.
protected Object
resolveObject(Object obj)
This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization.
protected Class<?>
resolveProxyClass(String[] interfaces)
Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.
int
skipBytes(int len)
Skips bytes.

      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

Read More »

What is LineNumberInputStream In Java ?

Class LineNumberInputStream

All Implemented Interfaces:
Closeable, AutoCloseable

Deprecated. 
This class incorrectly assumes that bytes adequately represent characters. As of JDK 1.1, the preferred way to operate on character streams is via the new character-stream classes, which include a class for counting line numbers.

@Deprecated
public class LineNumberInputStream

LineNumberInputStream class is an input stream filter that provides the added functionality of keeping track of the current line number.

A line is a sequence of bytes ending with a carriage return character ('\r'), a newline character ('\n'), or a carriage return character followed immediately by a linefeed character. In all three cases, the line terminating character(s) are returned as a single newline character.

The line number begins at 0, and is incremented by 1 when a read returns a newline character.

Constructor Summary of LineNumberInputStream:

Constructor
Description
LineNumberInputStream(InputStream in)
Deprecated.
Constructs a newline number input stream that reads its input from the specified input stream.

Method Summary of LineNumberInputStream:

Modifier
Method Name
Description
int
available()
Deprecated.
Returns the number of bytes that can be read from this input stream without blocking.
int
getLineNumber()
Deprecated.
Returns the current line number.
void
mark(int readlimit)
Deprecated.
Marks the current position in this input stream.
int
read()
Deprecated.
Reads the next byte of data from this input stream.
int
read(byte[] b, int off, int len)
Deprecated.
Reads up to len bytes of data from this input stream into an array of bytes.
void
reset()
Deprecated.
Repositions this stream to the position at the time the mark method was last called on this input stream.
void
setLineNumber(int lineNumber)
Deprecated.
Sets the line number to the specified argument.
long
skip(long n)
Deprecated.
Skips over and discards n bytes of data from this input stream.

      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

Read More »

Monday, 15 May 2017

What is InputStream Class In Java ?

Class InputStream

All Implemented Interfaces:
Closeable, AutoCloseable

Direct Known Subclasses:
AudioInputStream, ByteArrayInputStream, FileInputStream, FilterInputStream, InputStream, ObjectInputStream, PipedInputStream, SequenceInputStream, StringBufferInputStream

Declaration of InputStream:
public abstract class InputStream
extends Object
implements Closeable

InputStream is an abstract class and superclass of all classes representing an input stream of bytes.

Applications that need to define a subclass of InputStream must always provide a method that returns the next byte of input.

Constructor Summary of InputStream:

Constructor
Description
InputStream()
Default Constructor.

Method Summary of InputStream:

Modifier
Method Name
Description
int
available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
void
close()
Closes this input stream and releases any system resources associated with the stream.
Void
mark(int readlimit)
Marks the current position in this input stream.
Boolean
markSupported()
Tests if this input stream supports the mark and reset methods.
abstract int
read()
Reads the next byte of data from the input stream.
int
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer array b.
int
read(byte[] b, int off, int len)
Reads up to len bytes of data from the input stream into an array of bytes.
Void
reset()
Repositions this stream to the position at the time the mark method was last called on this input stream.
long
skip(long n)
Skips over and discards n bytes of data from this input stream.

      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

Read More »