问题标签 [writefile]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
166 浏览

ant - 使用 Ant 在文件中写入文件夹名称及其大小

我需要一些关于 Ant 的帮助。我想使用 Ant 创建一个文件,该文件包含一些名称和某些文件夹的大小(以 kb 为单位),还包含其他类型的数据(不是大小)但具有相同的模式。像这样的东西:

并且还要计算一些文件夹大小的总和(例如foldersum=folder1+folder2)并将其写入文件中:

0 投票
1 回答
342 浏览

c++ - hidapi:发送小于 caps.OutputReportByteLength 的数据包

我正在使用一个通过 DATA 管道接收命令的设备(wiimote),并且只接受与命令本身一样长的命令数据包。例如,它将接受:

但它不会接受:

这是 windows 上的一个问题,因为 windows 上的 WriteFile() 要求传递给它的 byte[] 至少与 caps.OutputReportByteLength 一样长。在不存在此限制的 mac 上,我的代码可以正常工作。以下是 hid.c 中导致此问题的代码:

如评论中所述,删除上述代码会导致 WriteFile() 出错。

有什么方法可以将数据传递给任意大小的设备?提前感谢您的任何帮助。

0 投票
1 回答
646 浏览

java - 读取和写入二进制文件 java.io.EOFException

我想要从文件 items.dat 中读取信息的程序,然后创建另一个名为 availableItems.dat 的文件,其中仅包含可用项目(数量大于 0)的信息(条形码、数量、价格),然后是预期收入从出售所有这些物品。预期收入可以用所有物品的数量*价格之和来衡量……我这样做了,但是有 EOFException 异常,我不知道为什么?

文件中的信息记录如下:

77777 5 6.7 .. .. 至 6 件

我的代码是:

0 投票
1 回答
104 浏览

java - 小/烦人的错误 - 与阅读/写作/分析文本文件有关

所以我正在编写的程序读取 3 个不同的文本文件。一个文本文件包含名称,另外两个包含标记。

现在我已经正确地完成了所有事情,但是我想添加一件事,但我没有运气做对。

所以现在输出文件如下所示:

因此,我的程序根据名称从带有名称的文本文件中打印出顺序。例如,其中一个包含所有名称的文本文件的顺序是:Alan /n Betty /n Chris

现在我不希望订单出现在文本文件中的名称中,我希望订单是降序聚合标记。所以顺序应该是:

这么久以来,我尝试了许多不同的解决方案,但都失败了。

程序代码:

}

0 投票
4 回答
18340 浏览

c - 同时写入和读取文件

我一直在尝试同时读取和写入文件,并且尝试将 text.txt 内容中的所有选项卡替换为空格。这是我的代码:

text.txt 的内容是这样的:

嗨 \t 我的 \t 名字 \t 是 \t 杰克!

当我运行这段代码时,我在 text.txt 文件中的输出只是空白。那里没有字符。我应该怎么做才能使替换按预期进行?

0 投票
1 回答
250 浏览

c++ - WriteFileGather - 将缓冲区附加到文件

使用 Windows API WriteFileGather,我正在将文件写入磁盘。我想将新缓冲区附加到现有文件中。防止WriteFileGather覆盖现有文件的方法是什么?

0 投票
1 回答
126 浏览

c++ - 三个嵌套对象到 C++ 中的文件 *.txt

我想将一个对象写入文件 (*.txt)

我想将类答案表写入和读取文件(* .txt),但在 C++ 中没有像在 Java 中那样编写对象:(

0 投票
1 回答
4980 浏览

visual-studio-2012 - WriteFile 失败并出现错误 87(参数不正确),但在 Visual Studio 中调试时工作正常

我创建一个文件:

然后写信给它:

当我启动程序时,WriteFile 失败并且 GetLastError() 返回错误 87。

我读到,当 dataSize 不是硬盘扇区大小的倍数时,使用标志 FILE_FLAG_NO_BUFFERING 创建的文件上的 WriteFile 失败。如果这是错误的原因,那么为什么当我在 Visual Studio Express 2012 中调试时代码可以正常工作?

0 投票
1 回答
140 浏览

yeoman - Create/update file(s) post dependency install, with Yeoman generator

I would like to create/update file(s) after the dependencies have been installed, when the generator(generator-custom) has been executed.

$ yo custom

Any pointer would be very helpful.


For example, I am trying to update the devDependencies section of the package.json with respect to the dependent packages devDependencies after the dependencies have been installed. However I am unable to achieve it. Please find the below code snippet.

The idea behind updating the package.json, was to rerun the installDependencies function. So that when ever the core package updates its dependency, the generator does not require to update its template.

As suggested by @SimonBoudrias, the above is not efficient way to perform the operation. The dependent packages can be installed by using peerDependencies of the main dependent package.


0 投票
2 回答
231 浏览

java - Don't write text into my txt file

With this code I want to read one text file, put all elements into a arraylist and replace the file with the the arraylist contain. But this code don't write into file and I don't know why...