io - 如何使用dart2js读取stdin和写入stdout

标签 io dart stdin rhino dart2js

根据这个answer

the dart:io libraries are only for the server/command-line, so they can't be compiled with dart2js.



是否可以使用dart2js从stdin读取并写入stdout中,例如:
$ java -jar ../../Downloads/rhino1_7R4/js.jar myjs.js < in.txt > out.txt

我正在考虑编辑dart2js生成的文件并添加如下内容:
importPackage(java.io);
importPackage(java.lang);
scan = new BufferedReader( new InputStreamReader(System['in']) );

最佳答案

dart2js用于在浏览器中运行。
dart:io不会转换为JS,因为浏览器不支持此功能(例如stdout / stdin)。

您是否要使用Rhino运行在服务器上运行的Dart生成的JS?
也许您可以将Dart VM集成到您的应用中并运行Dart代码,而无需转换为JS。

关于io - 如何使用dart2js读取stdin和写入stdout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20963416/

相关文章:

C - 替换单词

parsing - 两个 Haskell 程序如何通过 stdin 和 stdout 交换整数值而不将数据视为文本?

golang - 使用 io.Copy 将奇怪的字符从 bufio.Reader 复制到 STDOUT

java - 将依赖注入(inject)与 Apache Commons IO 结合使用

dart - Flutter(Dart)如何在点击应用程序时将副本添加到剪贴板?

listview - 如何让Flutter ListView像图片一样有边框半径

控制台 I/O : printf & scanf not occurring in expected order

c++ - printf 与 cstdio 和 iostream 在汇编级别上的差异

c - 我的文件中出现了奇怪的字符。我在C语言中使用无缓冲I/O流

listview - Flutter:使用ListView.builder消失SliverAppBar