Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

public static void main(String[]args) throws IOException {

  Scanner sc = new Scanner(System.in);

  String line;

  while((line=sc.readLine())!=null)

     System.out.println(line);
}

What's so verbose about it?



So, that actually is going to have problems with binary data in the file. However, you are correct it doesn't need to be terribly verbose (not as efficient as it could be, but that is easily fixable): https://gist.github.com/cbsmith/9755809

It's amazing though how often the solutions posted are just wrong.


You didn't import Scanner, and java.util.Scanner (what I assume you are using) does not have a readLine method. :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: