tag:blogger.com,1999:blog-694855878384792308.post1726140705727331230..comments2024-03-21T06:26:49.387-07:00Comments on Java67: Difference between FileReader vs FileInputStream in Java? Answerjavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-694855878384792308.post-43730981394165101282021-10-25T10:47:19.713-07:002021-10-25T10:47:19.713-07:00the writing is very good, i actually understand it...the writing is very good, i actually understand it , thank you .abchttps://www.blogger.com/profile/11488775860737964847noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-27854421362889228132021-04-25T23:52:30.048-07:002021-04-25T23:52:30.048-07:00Yes, that's correct only difference is that ou...Yes, that's correct only difference is that outstream is compared with writer instead of reader because you write on output stream and you read from input streamjavin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-33699348392117421102021-04-08T08:59:50.232-07:002021-04-08T08:59:50.232-07:00Probably, OutputStream the same meaning.Probably, OutputStream the same meaning.anar1501https://www.blogger.com/profile/10773242565552913390noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-138287517605388532021-04-08T08:59:13.706-07:002021-04-08T08:59:13.706-07:00Is it the same meaning even FileOutputStream?Is it the same meaning even FileOutputStream?anar1501https://www.blogger.com/profile/10773242565552913390noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-41819988016345129482020-03-06T04:42:33.903-08:002020-03-06T04:42:33.903-08:00Hello Nagraj and Unknown, sorry I see your questio...Hello Nagraj and Unknown, sorry I see your question now after an year. The difference lies in their purpose - FileReader is meant for reading streams of characters, while For reading streams of raw bytes, consider using a FileInputStream.<br /><br />Also, when you use FileReader default character encoding is used. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-34106303689066047502020-03-05T22:18:43.400-08:002020-03-05T22:18:43.400-08:00I am also confused as I do not see any difference....I am also confused as I do not see any difference. The apparent difference seems to be because of the change shown below.<br />In case of FileReader we are casting i to char before printing.<br />while(i != -1){<br /> System.out.print((char)i);<br /> i = fr.read();<br /> }<br />However in case of FileInputStream we are not.<br />while(b != -1){<br /> System.out.print(b);<br /> b = fis.read();<br /><br />I have casted b also to char before printing, so I am able to see the whole text instead of int representation of bytes.<br />Nagarajhttps://www.blogger.com/profile/09803117737663172769noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-65803215272276699532018-08-01T12:32:54.997-07:002018-08-01T12:32:54.997-07:00Hi Javin, Can you please clear my confusion on the...Hi Javin, Can you please clear my confusion on these queries..<br /> 1.Does the difference of these 2 classes boil down to how data is read only and not in how the data TO BE read(ie the file) is stored?<br />2. For example we use reader to read form txt file while we use inputstream to read from an excel(apache poi API). Then how come both return characters and not binary data?For eg apache poi api gets the exact cell value in character format and not in binary. So i am really confusedAnonymoushttps://www.blogger.com/profile/12056833396625762305noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-82646169034652856322016-09-10T07:35:02.138-07:002016-09-10T07:35:02.138-07:00Love reading on Java67 and Javarevisited.... you g...Love reading on Java67 and Javarevisited.... you guys write very clearly to make the concept understandable...Sugandhanoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-66832990262442620562016-03-09T23:32:52.455-08:002016-03-09T23:32:52.455-08:00Good, neat explenation. Question: why does main th...Good, neat explenation. Question: why does main throws IOE instead of catching it in the try statements?Anonymoushttps://www.blogger.com/profile/11041499728755555522noreply@blogger.com