Tag Archives: Java-I/O

Java.io.OutputStreamWriter Class methods

OutputStreamWriter class connects character streams to byte streams. It encodes Characters into bytes using a specified charset. Declaration : public class OutputStreamWriter extends Writer Constructors : OutputStreamWriter(OutputStream geek_out) : Creates a “geek_out” OutputStreamWriter that uses a default charset for encoding. OutputStreamWriter(OutputStream geek_out, Charset geek_set) : Creates a “geek_out” OutputStreamWriterthat uses a “geek_ set” charset for… Read More »

Java.io.ObjectInputStream Class in Java | Set 2

Java.io.ObjectInputStream Class in Java | Set 1 Note : Java codes mentioned in this article won’t run on Online IDE as the file used in the code doesn’t exists online. So, to verify the working of the codes, you can copy them to your System and can run it over there. More Methods of ObjectInputStream… Read More »

Java.io.ObjectInputStream Class in Java | Set 1

ObjectInputStream Class deserializes the primitive data and objects previously written by ObjectOutputStream. Both ObjectOutputStream and ObjectInputStream are used as it provides storage for graphs of object. It ensures that the object it is working for, matches the classes of JVM i.e Java Virtual Machine. Only those Object can be read from the streams that supports… Read More »

Java.io.FilePermission Class in Java

java.io.FilePermission class is used to represent access to a file or a directory. These accesses are in the form of a path name and a set of actions associated to the path name(specifies which file to be open along with the the extension and the path). For Example, in FilePermission(“GEEKS.txt”, “read”) “GEEKS.txt” is the path… Read More »

Java.io.BufferedReader Class in Java

Reads text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines. The buffer size may be specified, or the default size may be used. The default is large enough for most purposes. In general, each read request made of a Reader causes a corresponding read… Read More »

Java.io.FilterReader class in Java

Abstract class for reading filtered character streams. The abstract class FilterReader itself provides default methods that pass all requests to the contained stream. Subclasses of FilterReader should override some of these methods and may also provide additional methods and fields. Constructor : protected FilterReader(Reader in) : Creates a new filtered reader. Methods: void close() :… Read More »

Java.io.ObjectOutputStream Class in Java | Set 2

Java.io.ObjectOutputStream Class in Java | Set 1 More Methods: void write(byte[] buf) : Writes an array of bytes. This method will block until the byte is actually written. Syntax :public void write(byte[] buf) throws IOException Parameters: buf – the data to be written Throws: IOException void write(byte[] buf, int off, int len) : Writes a… Read More »

Java.io.ObjectOutputStream Class in Java | Set 1

An ObjectOutputStream writes primitive data types and graphs of Java objects to an OutputStream. The objects can be read (reconstituted) using an ObjectInputStream. Persistent storage of objects can be accomplished by using a file for the stream. Only objects that support the java.io.Serializable interface can be written to streams. The class of each serializable object… Read More »

Java.io.FilterWriter class in Java

Abstract class for writing filtered character streams. The abstract class FilterWriter itself provides default methods that pass all requests to the contained stream. Subclasses of FilterWriter should override some of these methods and may also provide additional methods and fields. Constructor : protected FilterWriter(Writer out) : Create a new filtered writer. Methods : void close()… Read More »

Java.io.StringReader class in Java

This a character stream class whose source is a string. Constructor: StringReader(String s) : Creates a new string reader. Methods : void close() : Closes the stream and releases any system resources associated with it.Once the stream has been closed, further read(), ready(), mark(), or reset() invocations will throw an IOException. Closing a previously closed… Read More »

Java.io.Writer class in Java

This abstract class for writing to character streams. The only methods that a subclass must implement are write(char[], int, int), flush(), and close(). Most subclasses, however, will override some of the methods defined here in order to provide higher efficiency, additional functionality, or both. Constructor protected Writer() : Creates a new character-stream writer whose critical… Read More »