• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why my file reading skipping the first line?  RSS feed

 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My file is salt.txt and it has the following

ahmed zenza::[B@2626b418
zen ye::[B@5a07e868

Here i read the contents in constructor,


output is

Please enter command:
======================
FileSystem -i (if Admin)
FileSystem (if you are authorised user)
Q (to quit File Server)
Enter: FileSystem -i
Salt File Exists
zen ye::[B@5a07e868
[zen ye=:[B@5a07e868]
Hash File Exists
Key zen ye Hash -108786318372261550952593739922654342545 lvl 2

-------------------------

Why only one name giving out?
Thanks


 
Tim Harris
Ranch Hand
Posts: 57
3
Chrome Eclipse IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the documentation for readLine. Then look at your code. What do you think might be happening?
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Methods suppose to start with lower case. So it should be "salt()", not "Salt()".
2. Line 3 variable name poorly chosen. You could choose something more meaningful (maybe "fileExist") and that comment would become redundant.
3. Lines 8 to 12 are redundant. You could add "salt.exists()" check to line 14 "if". No?
4. If you don't follow top remark, on line 14 you shouldn't be writting "exist == true" it is error-prone.
You could easily make a mistake and get unexpected outcome like:
I believe you can notice what is wrong with code snippet above.
5. Your method "salt" is the way too long. It does more things than it suppose to do. you should decompose it and get more derived methods. Think about what these could be.
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks..that helped me
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!