You are here:   HomeJava ProgrammingStream
by Dinesh Thakur Category: Stream

We use two classes FileInputStream, FileOutputStream i.e to read data from one file and write it to another file.

 
by Dinesh Thakur Category: Stream

The BitSet class is used to create objects that maintain a set of bits. The bits are maintained as a growable set. The capacity of the bit set is increased as needed. Bit sets are used to maintain a list of flags that indicate the state of each element of a set of conditions. Flags are boolean values that are used to represent the state of an object. It is used for representing a set of true and false values.

 
by Dinesh Thakur Category: Stream

The java.io.BufferedReader and java.io.BufferedWriter classes are the character based equivalents of the byte oriented BufferedlnputStream and BufferedOutputStream classes.



 
by Dinesh Thakur Category: Stream

RandomAccessFile provides you to read or write data from or to in a file at any location. It supports you to move around the file, and read from it and write to it, where ever you like.

 
by Dinesh Thakur Category: Stream

To read a character form the Buffered Reader object, use the following version of read() method. int read( ) throws IOException

The method read() will return a integer value corresponding the character from the input stream and if end of the stream come across then it will return -1.

 
by Dinesh Thakur Category: Stream

Java also allows you to access the contents of a file in random order i.e. data items can be read and written in any order. This is especially useful in direct access applications such as banking systems, airline reservation systems, Automatic Teller Machine (ATM) etc. where the desired information must be located immediately. Random access files (or direct access files) are analogous to arrays, where each element is accessed directly by means of its index number. Java provides java.io.RandomAccessFile class that enables you to perform random access file input and output operations as opposed to sequential file I/O offered by ByteStream and CharacterStream classes.



 
by Dinesh Thakur Category: Stream

Java makes available a set of classes and methods that allows you to read from and write to files. Java supports both streams and methods to read from and write to file respectively.



 
by Dinesh Thakur Category: Stream

Java provides java.io.FileReader and java.io.FileWriter classes for reading from and writing characters to a file. The FileReader and FileWri ter classes can be used almost identically to the FileInputStream and FileOutputStream character stream classes.



 
by Dinesh Thakur Category: Stream

In this Java Example in the main () method of the class FileIOStream, an instance fileOutput of FileOutputStream is created to write to the file mydata.dat. Then using the for loop, we write the square of the value stored in the index variable i using the write () method to the file mydata.dat. The output stream is then closed by calling the close () method.



 

Page 1 of 6



Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article