I/O streams in java

i/o streams in java,Input/Output Streams in Core Java,Java I/O Tutorial

Java IO at a Glance

Java I/O Streams – Overview File Copying Semantics of File copying – FileInputStream and FileOutputStream Skipping a few bytes in a file and reading File copying – Using FileReader & FileWriter Reading data types using DataInputStream and DataOutputStream Merging of files – SequenceInputStream Reading and writing sequentially and randomly – Using RandomAccessFile Filter Streams – …

Java IO at a Glance Read More »

StringWriter vs StringBuilder

StringWriter vs StringBuilder given in simple terms for Beginner. Even though, some string word is common in both of them (like Java and JavaScript), both are very different in their functionalities. We cannot compare them because both are very different from different packages. 1. StringWriter StringWriter from java.io package is a stream class capable to …

StringWriter vs StringBuilder Read More »

Java File Copying

1. Semantics of File copying – FileInputStream and FileOutputStream 2. Using FileReader & FileWriter 3. Rereading a file – Using markSupported(), mark() & reset() 4. Skipping a few bytes in a file and reading 5. Reading data types using DataInputStream and DataOutputStream 6. Reading and writing sequentially and randomly – Using RandomAccessFile 7. Merging of …

Java File Copying Read More »

File Copying FileReader FileWriter

We have seen earlier, clearly the style and basics of file copying in Java, with byte streams FileInputStream and FileOutputStream in "Semantics of File Copying" and the it&339;s drawbacks of file copying in "Performance drawbacks of file copying". Now let us do the same job but with character streams – FileReader and FileWriter. The same …

File Copying FileReader FileWriter Read More »

markSupported() mark() reset() Java

Rereading from the Same Position The same contents of a file can be again and again read by marking the position with the methods of StringBufferInputStream, inherited from its super class InputStream. A file can be reread (reading again) from a particular location. Here, the file position is marked; execution control is taken back to …

markSupported() mark() reset() Java Read More »

Performance drawbacks File copying

Performance drawbacks File copying Summary: By the end of this tutorial "Performance drawbacks File copying", you will come to know the reasons of slow performance in file copying. Gives links to other programs to increase speed of copying. Performance drawbacks of FileInputStream and FileOutputStream Following is the for loop used in the FileToFile1.java program. while( …

Performance drawbacks File copying Read More »

StringBufferInputStream Example

StringBufferInputStream Example: As in the earlier program, where the source of reading is a byte array in case of ByteArrayInputStream, now the source is a string buffer in case of StringBufferInputStream. That is, StringBufferInputStream reads from a string buffer (or the other way, string). StringBufferInputStream class methods and constructors are deprecated (observe the compiler message …

StringBufferInputStream Example Read More »

ByteArrayOutputStream

The class ByteArrayOutputStream does just the opposite functionality of ByteArrayInputStream. The ByteArrayInputStream reads data from the array and now the ByteArrayOutputStream writes the data to the byte array. All the characters of the array can be written or a few also. In the following program, both functionalities are illustrated. import java.io.*; public class BAODemo { …

ByteArrayOutputStream Read More »