Any way to have an ActionScript 3 (Flex/AIR) project print to standard output?

后端 未结 4 1788
忘了有多久
忘了有多久 2021-01-12 07:34

Is there any way to have a binary compiled from an ActionScript 3 project print stuff to stdout when executed?

From what I\'ve gathered, people have been go

4条回答
  •  甜味超标
    2021-01-12 08:26

    With AIR on Linux, it is easy to write to stdout, since the process can see its own file descriptors as files in /dev.

    For stdout, open /dev/fd/1 or /dev/stdout as a FileStream, then write to that.

    Example:

    var stdout : FileStream = new FileStream();
    stdout.open(new File("/dev/fd/1"), FileMode.WRITE);
    stdout.writeUTFBytes("test\n");
    stdout.close();
    

    Note: See this answer for the difference between writeUTF() and writeUTFBytes() - the latter will avoid garbled output on stdout.

提交回复
热议问题