问题标签 [bufferedwriter]

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 回答
11138 浏览

java - JAVA:IO 异常:原因流已关闭

为什么我会收到以下异常?我正在做的是逐行将一个巨大的 ArrayList 写入磁盘上的文件。生成的文件大约 >700MB。逐行编写时似乎有一些问题。文件的大小可能是一个原因吗?为什么要关闭流?顺便说一句,我正在使用 Windows 操作系统。

例外情况如下:

0 投票
0 回答
262 浏览

mysql - 在 JSP 中将一个非常大的 ResultSet 渲染到屏幕上

我是初学者,请耐心等待!;-)

MySQL我需要以表格的形式在屏幕上的查询中显示一个非常大的 ResultSet(超过 15.000 行)HTML。我正在使用JSP页面来尝试完成此操作。

查询本身在我的服务器上大约需要 0.25MySQL秒(命令行,通过终端),但在浏览器上呈现最少的HTML.

如果我使用类似的东西将结果写入文件new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename),"ISO-8859-1")),它也非常快(1.2s),但这不是客户想要的。

所以我想我的问题是:有什么方法可以使用 将OutputStreamWriter结果打印到屏幕上,而不是将它们写入文件?我假设这out.print就是造成巨大延误的原因。

非常感谢!

0 投票
3 回答
1325 浏览

java - Java - 无法完成写入文本文件

我需要处理一个大文本文件(大约 600 MB)才能正确格式化,将格式化的输出写入一个新的文本文件。问题在于将内容写入新文件时会停止在大约 6.2 MB 处。这是代码:

我已经在寻找答案,但问题通常与作者没有被关闭或没有flush()方法有关。因此,我认为问题出在 BufferedReader 中。我错过了什么?

0 投票
1 回答
2741 浏览

c# - c#中java BufferedReader的等价物是什么?

可能重复:
.NET 等效于 Java 的 BufferedReader

这是我的 Java 代码。我想将其转换为 c#。你能帮我么?

0 投票
3 回答
2609 浏览

java - BufferedWriter.write() 似乎不起作用

我有两个 Java 应用程序,其中一个 Android 客户端连接到计算机上的服务器并使用 BufferedWriter 通过 websockets 发送消息。

客户端:

服务器:

ConnectionThread班级:

当我运行服务器,然后运行客户端时,客户端将显示“已连接!” toast,服务器的输出将是:

因此,似乎实际上正在建立连接,但消息没有到达。有谁知道为什么会发生这种情况?

0 投票
5 回答
12402 浏览

java - Java 文件 I/O 的良好实践

我正在尝试从文件中读取整数,对它们应用一些操作并将这些结果整数写入另一个文件。

我想问这样包装这些输入和输出流是一种好习惯吗?
我是 Java 新手,在互联网上,我在文件中看到了许多其他 I/O 方式。我想坚持一种方法,所以高于最好的方法吗?

0 投票
2 回答
775 浏览

java - 输出未像使用 FileWriter 那样打印到文件

所以我的程序编译但是在测试早期分析时我意识到它不会打印显示所有输出的文件。有人可以告诉我为什么文件根本没有被打印吗?这是我的代码...

0 投票
2 回答
1397 浏览

java - 在不丢失信息的情况下更新文本文件

这部分代码替换文件中的信息,如何保存信息并每次更新呢?我的意思是我想在文本文件中有答案的历史。

0 投票
2 回答
281 浏览

java - 导出到 .jar 文件时“\n”不起作用

我有一个我编写的程序的输出文件。它由 FileWriter 和 BufferedWriter 编写。

后来我使用类似于的行写入文件。

当我在 Eclipse 中简单地运行程序时,输出文件的格式正确,每条消息都写在一个新行上。但是,当我导出到 .jar 文件时,它不再起作用,并且将每条消息放在一行上,就好像“\n”不起作用一样。

我是否错误地使用了 FileWriter/BufferedWriter,或者它在 .jar 文件中不起作用?

0 投票
8 回答
49861 浏览

java - BufferedWriter not writing everything to its output file

I have a Java program that reads some text from a file, line by line, and writes new text to an output file. But not all the text I write to my BufferedWriter appears in the output file after the program has finished. Why is that?

The details: the program takes a CSV text document and converts it into SQL commands to insert the data into a table. The text file has more than 10000 lines which look similar to following:

The program seems to work fine except it just stops in the file randomly half way through creating a new SQL statement having printed it into the SQL file. It looks something like:

This happens after about 10000 lines but several hundred lines before the end of the file. Where the break happens is between a 1 and a ,. However, the characters doesn't seem important because if I change the 1 to a 42 the last thing written to the new file is 4, which is cutting off the 2 from that integer. So it seems like the reader or writer must just be dying after writing/reading a certain amount.

My Java code is as follows: