Skip to content

Instantly share code, notes, and snippets.

@ranha
Created October 13, 2011 03:13
Show Gist options
  • Save ranha/1283261 to your computer and use it in GitHub Desktop.
Save ranha/1283261 to your computer and use it in GitHub Desktop.
Dartでファイルから1バイト読み込もうとする
dartcでコンパイルしようとした場合次のようになる
ranha@ranha:~/dart_full/dart$ ./out/Debug_ia32/dartc ~/dart/read1bytefromfile.dart
file:/home/ranha/dart/read1bytefromfile.dart/read1bytefromfile.dart:9: no such type "File"
8: main() {
9: var f = new File("read1bytefromfile.dart",false);
file:/home/ranha/dart/read1bytefromfile.dart/read1bytefromfile.dart:9: New expression does not resolve to a constructor
8: main() {
9: var f = new File("read1bytefromfile.dart",false);
Compilation failed with 2 problems.
dartでは実行出来る
% dart_bin read1bytefromfile.dart
#
#import("dart:coreimpl");
String char2string(int char)
{
return StringBase.createFromCharCodes([ char ]);
}
main() {
var f = new File("read1bytefromfile.dart",false);
int i = f.readByte();
print(char2string(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment