Some ways to read from and write into file (Java)