Series: IO File copy

IO Streams introduction and file copying

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 »

Byte streams vs Character streams

Byte streams vs Character streams: Character streams Advantages over Byte streams Byte streams read bytes that fall under ASCII range and character streams read Unicode characters that include characters of many international languages. Being latest, introduced with JDK 1.1, the character streams are advantageous over byte streams like the inclusion of newLine() method (that is …

Byte streams vs Character streams Read More »

File Copy Tutorial Java

File Copy Tutorial Java: File copying operation, in Java, can be done in 5 steps broadly. Open the source file in read mode (say, using FileInputStream constructor) Open the destination file in write mode (say, using FileOutputStream constructor) Read data from the source file (say, using read() method) Write data to the destination file (say, …

File Copy Tutorial Java 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 »

Chaining Streams Java

Chaining Streams Java Java comes with low-level byte streams and high-level byte streams and similarly low-level and high-level character streams. Sub classes of FilterInputStream and FilterOutputStream are known as high-level streams. There are four high-level streams on input streams side – LineNumberInputStream, DataInputStream, BufferedInputStream and PushbackInputStream. The job of high-level streams is to add extra …

Chaining Streams Java Read More »

BufferedInputStream BufferedOutputStream

Using Buffers to Enhance the Performance Buffering of streams increases the performance to higher extents of few thousand times. For buffering, two streams exist in java.io package in byte streams category – BufferedInputStream and BufferedOutputStream. These high-level classes are subclasses of FilterInputStream and FilterOutputStream and their functionality is to increase the performance with buffer. These …

BufferedInputStream BufferedOutputStream Read More »

DataInputStream DataOutputStream File Copy

DataInputStream and DataOutputStream are high-level classes as they are the subclasses of FilterInputStream and FilterOutputStream. These streams' extra functionality is that they can read or write integers, doubles and lines at a time, instead of byte by byte. This increases the performance to some extent; instead of reading and writing byte by byte with FileInputStream …

DataInputStream DataOutputStream File Copy Read More »

BufferedReader and BufferedWriter File Copy

Speed up Copying Reading and copying file to file is very slow with FileReader and FileWriter as for every byte read, the control should be shifted from the execution context area of source file to the destination file and back again to read the second byte. This is what you have done in Semantics of …

BufferedReader and BufferedWriter File Copy Read More »

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 »

Data Types Read Write Java

DataInputStream includes many methods like readByte(), readInt(), readLong(), readFloat(), readDouble() and readUTF() etc with which a byte, an integer, a long, a float, a double and a word can be read as a whole. Similarly, the DataOutputStream includes the methods like writeByte(), writeInt(), writeLong(), writeFloat(), writeDouble() and writeUTF() that can write a byte, an integer, …

Data Types Read Write Java Read More »