如何使用Dart Editor将print()输出直接发送到文件? [英] How to send print() output directly to a file with Dart Editor?

查看:180
本文介绍了如何使用Dart Editor将print()输出直接发送到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了这些 ch04-tools -editor 开始并在Google上搜索,但我没有找到任何答案。如何使用Dart编辑器将print()输出直接发送到文件?

I read those ch04-tools-editor, get-started and searched on Google, but I didn't find any answers. How to send print() output directly to a file with Dart Editor?

编辑:我想发送(管道/重定向流)数据)直接在文件中,而不是Dart编辑器。我正在寻找Dart编辑器的一个功能。

EDIT : I want to send (pipe/redirect stream) the data (what print() return) directly in a file, instead the Dart Editor. I'm looking for a feature of the Dart Editor.

推荐答案

print() 不会输出到文件;它输出到控制台( stdout 在控制台应用程序,浏览器中的浏览器控制台)。

print() doesn't output to files; it outputs to the console (stdout in console apps, the browser console in browsers).

dart:io 图书馆优惠大量的I / O功能,包括读写文件。例如:

The dart:io library offers plenty of functionality for I/O, including reading and writing files. One example:

import 'dart:io';

void main() {
  var out = new File('output.txt').openWrite();
  out.write("String written to file.\n");
  out.close();
}

更新:寻找一个自动将控制台输出写入文件的Dart编辑器功能。据我所知,没有这样的功能。您的选项包括:

Update: As per your updated question, you're looking for a Dart Editor feature that automatically writes console output to a file. To the best of my knowledge, there's no such feature. Your options include:


  1. 如上所示手动写入文件。

  2. 复制控制台输出

  3. 从Dart编辑器外部运行应用程序。例如,在任何类UNIX系统上,您可以像这样重定向 stdout

dart my-app.dart >output.txt


  • 修改Dart编辑器源)添加您想要的功能。

  • 这篇关于如何使用Dart Editor将print()输出直接发送到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆