-
-
Save anonymous/9c700b511e5c9e1bb385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#this is the program | |
$cat Main.java | |
import java.util.stream.*; | |
import java.nio.file.*; | |
class Main { | |
public static void main( String ... args ) throws Exception { | |
String s = Files.lines(Paths.get("file.txt")).collect(Collectors.joining("\n")); | |
System.out.println(s); | |
} | |
} | |
#wc -c counts the number of characters in the file | |
$wc -c file.txt | |
14 file.txt | |
# od -c shows all the characters in the file (including invisible ones as line endings) | |
$od -c file.txt | |
0000000 h e l l o \r \n w o r l d \r \n | |
0000016 | |
# if we run the program the output is modified | |
$java Main | wc -c | |
12 | |
# we've got 12 instead of 14 | |
# the \r was stripped | |
$java Main | od -c | |
0000000 h e l l o \n w o r l d \n | |
0000014 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment