Created
July 28, 2014 15:54
-
-
Save Getaji/0492fc09aef7579523b7 to your computer and use it in GitHub Desktop.
Scannerで改行をそのまま入れるよ! 速度は知らん。→計測したところ、改行文字を手動挿入するのと同じか若干早い模様です。やったね。
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
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) throws FileNotFoundException { | |
Scanner scanner = new Scanner(new FileInputStream("src/sample.txt")).useDelimiter(Pattern.compile("^")); | |
StringBuilder builder = new StringBuilder(); | |
while (scanner.hasNext()) { | |
builder.append(scanner.next()); | |
} | |
System.out.println(builder.toString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment