LiLi LiLi 3 3 silver badges 8 8 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Explaining the semiconductor shortage, and how it might end. Does ES6 make JavaScript frameworks obsolete? Featured on Meta. Now live: A fully responsive profile. Visit chat. Linked 1. Related Hot Network Questions.
Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings. How do objects become eligible for garbage collection? How to calculate date difference in Java Difference between Path and Classpath Is Java "pass-by-reference" or "pass-by-value"?
Difference between static and nonstatic methods java Why Java does not support pointers? What is package in Java?
What are wrapper classes? What is singleton class in Java? Can a top level class be private or protected in java Are Polymorphism , Overloading and Overriding similar concepts? Why can't a Java class be declared as static? Why does Java not support operator overloading? How to generate random integers within a specific range in Java What's the meaning of System. What is the purpose of Runtime and System class?
What is finally block in Java? What is difference between final, finally and finalize? What is try-with-resources in java? What is a stacktrace? What is the meaning of immutable in terms of String? Reader classes uses character encoding to decode bytes and return characters to caller. Reader can either use default character encoding of platform on which your Java program is running or accept a Charset object or name of character encoding in String format e.
Despite being one of the simplest concept, lots of Java developers make mistakes of not specifying character encoding, while reading text files or text data from socket. Remember, if you don't specify correct encoding, or your program is not using character encoding already present in protocol e. Some characters which are not present in default encoding, may come up as? Once you know this fundamental difference between stream and reader , understanding difference between FileInputStream and FileReader is quite easy.
Both allows you to read data from File , but FileInputStream is used to read binary data, while FileReader is used to read character data. This is similar to FileInputStream, which also provides similar constructors for reading from file source.
Though its advised to use BufferedReader to read data from file. On the other hand, in example 2 are reading data character by character. This is why you see exactly same text as written in file output from our example 2. Share to Twitter Share to Facebook.
Labels: core java , java IO tutorial , programming. April 13, at AM Dieter Adriaenssens said April 14, at AM pratik singhal said October 9, at AM Arun said December 3, at PM Anonymous said Thanks December 4, at AM Rajkumar said March 21, at PM. Newer Post Older Post Home. Subscribe to: Post Comments Atom. Subscribe for Discounts and Updates Follow. Search This Blog.
0コメント