Advise for a fresher
Do not expect command on Java I/O Streams overnight. It is ocean, until and unless not properly approached, it leaves in a very great confusion, of course without pointers (feeling of when you lost alone in an unknown forest). It is a ocean due to number of classes, and these classes are given to make your programming easy (not to confuse you). I feel the following is a better way to penetrate into Java Input/Output Tutorial; follow the following order of reading.
- A) General Programs
- Java I/O Streams – Overview
- Byte streams and Character streams
- Byte streams vs Character streams
- Semantics of File Copying
- Performance drawbacks of file copying
- BufferedInputStream and BufferedOutputStream
- Chaining of Streams
- DataInputStream and DataOutputStream – File Copying
- Skipping a part of a File
- Keyboard Input – DataInputStream
- Keyboard Input – BufferedReader
- Keyboard Input – Scanner – No parsing
- Scanner – Checking for Tokens
- SequenceInputStream – Merging Files
- ByteArrayInputStream
- ByteArrayOutputStream
- StringBufferInputStream
- Using markSupported(), mark() & reset()
- PrintStream
- Filter Streams in java.io Package
- Giving Line Numbers – LineNumberInputStream
- File Copying – FileReader & FileWriter
- BufferedReader & BufferedWriter
- CharArrayWriter – Storing Data
- StringReader
- StringWriter – Storing Data
- CharArrayReader – Reading from Character Array
- PrintWriter – Formatting Data
- PushbackReader – Pushing out Character
- Using OutputStreamWriter
- RandomAccessFile – Reading Sequentially and Randomly
- LineNumberReader – Giving Line Numbers
- PipedInputStream and PipedOutputStream
- File class – Retrieving Metadata of File
- File class – Changing File Properties
- StreamTokenizer – Tokenizing a Stream
- Performance tips in file copying
Keyboard Input (Scanf in Java)
- B) Compare and Contrast I/O classes. Important for Interviews.
- Byte streams vs Character streams
- PrintStream vs PrintWriter
- StringWriter vs StringBuilder
- StreamTokenizer vs StringTokenizer
- C) Miscellaneous increasing your programming skills.
- System.out.println()?
- What is System.in?
- Closeable and Flushable interfaces
- Number of Lines in a File
- Reading and writing arrays and strings
- Wrapper Streams
- Filter Streams
- Byte streams vs Character streams
//Here I post a nio charset program
package com.sam.CharSet;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
public class UnicodeToCharSet {
public static void main(String[] args) throws IOException {
Charset charset = Charset.forName(“utf-8”);
InputStreamReader isr = null;
isr = new InputStreamReader(new FileInputStream(new File(
“FILE Path”)), charset);
int i = 0;
while ((i = isr.read()) != -1) {
char c = (char) i;
System.out.print(c);
}
isr.close();
}
}
package com.sam.CharSet;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
public class UnicodeToCharSet {
public static void main(String[] args) throws IOException {
Charset charset = Charset.forName(“utf-8”);
InputStreamReader isr = null;
isr = new InputStreamReader(new FileInputStream(new File(
“FILE Path”)), charset);
int i = 0;
while ((i = isr.read()) != -1) {
char c = (char) i;
System.out.print(c);
}
isr.close();
}
}
Hello Sir..
I tried to find about NIO(New Input/Output) Package and all the things related to it on your blog but I couldn’t find anything. so my request is please post details about NIO. I jast want to know about it…so please sir Post all the details about it…!! officially it was introduced in java 1.7 version but actually it is from java 1.4 version.
Yes, I have not placed so far. I do it whenever fell leisure. But leisure is a rare item in my life. It will take 6 months.