Flex 3的/空气:编写新的空白行使用的FileStream文件 [英] Flex 3 / Air: Writing blank new lines to files using FileStream

查看:110
本文介绍了Flex 3的/空气:编写新的空白行使用的FileStream文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要直接写一些文字,以使用Flex 3 /空的文件。对文件中的文本(称之为Database.txt)必须具有以下格式:

I want to write some text directly to a file using Flex 3 / Air. The text on the file (call it "Database.txt") must have the following format:

1号线

2号线

行3

var FS:FileStream = new FileStream();
var DatabaseFile:File = File.desktopDirectory.resolvePath("Database.txt");
FS.open(DatabaseFile, FileMode.WRITE);
FS.writeUTFBytes("Line1" + "\n" + "Line2" + "\n" + "Line3");
FS.close();

但它写入以下文本文件:

But it writes the following text to the file:

1号线2号线行3。

我是pretty的肯定,我正在做一个很虚的错误,但我无法弄清楚它是什么。谁能帮我?

I'm pretty sure I'm making a very dummy error, but I cannot figure out what it is. Can anyone help me?

感谢您的时间:)

推荐答案

你是如何打开Database.txt?如果你正在使用的notepad.exe,它会出现在所有在同一行,因为NOTEPAD.EXE被延迟并且不支持Unix行结尾()。如果你绝对需要它在NOTEPAD.EXE被打开,你需要做的是使用Windows的行结束符,而不是( \ r \ñ)。所以,你的code看起来像:

How are you opening Database.txt? If you are using notepad.exe, it will appear all on one line, since notepad.exe is retarded and doesn't support unix line endings (\n). If you absolutely need it to be opened in notepad.exe, what you need to do is use windows line endings instead (\r\n). So your code would look like:

FS.writeUTFBytes("Line1" + "\r\n" + "Line2" + "\r\n" + "Line3");

但现在你也必须确保你的code可加载时txt文件返回到您的AIR应用程序(或者你可能最终与重复行)处理这些窗口的行结束符

But now you also have to make sure your code can handle these windows line endings when loading the txt file back into your AIR application (or you might end up with duplicate lines)

这篇关于Flex 3的/空气:编写新的空白行使用的FileStream文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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