3 ms·
Copy standard input to standard out? It's like 5 lines of code in Java Scanner scan = new Scanner(System.in) while(scan.hasNext()) { System.out.println(scan.
by sreya 13y ago
Copy standard input to standard out? It's like 5 lines of code in Java
Scanner scan = new Scanner(System.in)
while(scan.hasNext())
{
System.out.println(scan.nextLine()+"\n")
}
- cbsmith 13y agoOh good lord. This one adds in Scanner! How do you think this code will handle binary data? How do you think it'll handle a simple two line text file?
- deleted 13y ago[deleted]
- ASneakyFox 13y agoThere is no one solution fits all. Especially if the problem is imaginary.
- cbsmith 13y ago> There is no one solution fits all. Especially if the problem is imaginary. Yeah, but there are solutions that actually solve the problem.
- ASneakyFox 13y agowhat exactly is the problem? you cant just make up problems and ridicule the code for not solving them when the coder had no idea he was supposed to be solving them. This solution (and whatever solution you might have in mind) likely both dont solve all sorts of problems. for instance what if there is a power failure and you lose all the output? is it persisting to disk? what if new input methods that arent even thought of it come to exist 5 years from now, is it compatible with that?
- cbsmith 13y ago> This solution (and whatever solution you might have in mind) likely both dont solve all sorts of problems. for instance what if there is a power failure and you lose all the output? is it persisting to disk? what if new input methods that arent even thought of it come to exist 5 years from now, is it compatible with that? You are missing the point. The code doesn't work. I'd love to hear any interpretation of the problem where that code actually is correct.
- peterashford 13y agoAre you, like, paid for litres of Java hate per second or something?
- cbsmith 13y agoI'm not hating on Java. Java has perfectly good ways of solving this simply. My hate is on the Java code being posted here. It's horribly bad.