Created
September 6, 2018 02:52
-
-
Save nobeans/03ca936751bdb0e7d8ba1611e6fe1032 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
def f = new File("/tmp/test.dat") | |
f.text = "1234567890" * 2 | |
def tryRead(ins) { | |
def buff = new byte[9] | |
println ins.read(buff) | |
println new String(buff) | |
} | |
f.withInputStream { ins -> | |
tryRead(ins) | |
tryRead(ins) | |
tryRead(ins) | |
tryRead(ins) | |
tryRead(ins) | |
} | |
// 9 | |
// 123456789 | |
// 9 | |
// 012345678 | |
// 2 | |
// 90 <---EOFの直前までで一度正しく読み込める | |
// -1 | |
// <---EOF検出時にはデータは空 | |
// -1 | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment