4 Years
Discussion Span
Last Post by JamesCherrill

It's admirable that you have taken the time to create this tutorial to try to help others. But it's really not something I could recommend for a number of reasons...
Most seriously, the method used is completely wrong for reading text files. Converting byte to int to char by casting will work for ASCII text, but will fail for all characters and text in non English scripts. Java has a complete set of methods for correctly converting bytes in various encoding so to Unicode, and you MUST use one of those.
There are also some bad practices. Worst is creating an empty catch block - discarding Exceptions in a new program is a terrible mistake. Starting the class name with a lower case letter is also bad practice.
Reading a raw FileInputStream byte by byte is a horribly inefficient mistake. You should wrap it in a buffered stream.
Finally, you ignore the NIO classes that are the current best practice. Eg, you will find a method in the Files class that reads all the lines of a text file, with correct encoding, into a string array.

Please don't be discouraged. I hope you will find the time to create a new version of your tutorial that corrects these errors. You can also ask me or any other Java person here to review it before posting to the whole world, if you wish.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.