3 ms·
If you want a single point generalization about Java programmers, I was one for years, and the way I would have implemented this involves minimally a BufferedRe
by patio11 13y ago
If you want a single point generalization about Java programmers, I was one for years, and the way I would have implemented this involves minimally a BufferedReader and an InputStreamReader. You'll also probably need to catch the IOException. Plus or minus 20 lines or so.
I don't hate Java, but "Java as it is spoken" does not often get used for Unix-style piping in a chain of small programs on a command line. It also isn't the easiest tool in the drawer if you want to do light (or heavy) string processing.
- RyanZAG 13y agoSure, but I wouldn't bring my forklift out of storage to move a sack of potatoes across the room either which is what you're doing when you use Java for a 10 line shell script. That's not what Java is designed for.
- alandarev 13y agoNor you grab an camel when you want a ride, as there are better options.
- lern_too_spel 13y agoWrapping System.in in a Reader is exactly the wrong thing to do. You want to copy the bytes directly, not guess what the character encoding might. The input might not be characters at all.