Created
December 9, 2013 09:33
-
-
Save haruyama/7869684 to your computer and use it in GitHub Desktop.
file dumper
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 ceylon.file { File, Path, parsePath } | |
import ceylon.io { OpenFile, newOpenFile } | |
import ceylon.io.charset { utf8, Decoder } | |
import ceylon.io.buffer { ByteBuffer } | |
import java.util { ArrayList } | |
shared void cat(String filename) { | |
Path path = parsePath(filename); | |
OpenFile file = newOpenFile(path.resource); | |
try { | |
ArrayList<Integer> bytes = ArrayList<Integer>(); | |
file.readFully(void (ByteBuffer buffer) { | |
for (Integer byte in buffer) { | |
bytes.add(byte); | |
} | |
}); | |
print(bytes); | |
} finally { | |
file.close(); | |
} | |
} | |
shared void run(){ | |
if (nonempty args=process.arguments) { | |
for (arg in args) { | |
cat(arg); | |
} | |
} | |
else { | |
throw IllegalArgumentException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment