quiz
quiz copied to clipboard
quick refactor java parser
- Removed comments
- Set the
file
attribute as final - Created a constructor to get the
file path
and create the newfile
- Removed
set
andget
file methods - Switch from String to StringBuilder
- Switch while > 0 to while != -1
- Added
withUnicode
flag to do all the work in one method and avoid duplicated code - Deleted getContentWithoutUnicode
- Added try-finally-close for the input/output stream
- Check if the
content
var is not empty before write the content - Check if the
file
exists before write the content - Removed the
for
loop to write content as byte array - Added
sync
for both methods - Created Filter interface with 2 implementations: NoFilter and UnicodeFilter
- Switch from java6 try-finaly to java 7 try-with-resources
TODO
- Rename var
i
tofis
on getContent method - Check if
file
exists before try to read the content on saveContent method