English 中文(简体)
为今后操纵制作大量信函的最佳方式
原标题:Optimal way of generating a large sequence of letters for future manipulation

I m trying to generate 4 billion instances of random characters ranging from A-H and then storing it all into a text file in Java. I tried the baseline method of iterating until a counter reaches to 4B but I find that it always results in a memory problem.

我很想知道,把这些信件作为借方而不是作为特征的原始价值储存起来是否更为有效。 例如:

A <- 000, B <- 001, C <- 010, D <- 011, E <- 100, F <- 101, G <- 110, H <- 111

If so, how would I go about doing this?


Looking ahead, once I have a text file with all these randomly generated letters, what would the best method be for opening the txt file to make further modifications? e.g. replacing or appending a few characters. I looked into Java s tutorials and think that the Random Access Files will do the trick, but is there a better option?

我是否应当增加一条新路线,说明每 n,使阅读的新线功能成为阻截点?

I guess to concisely state my questions, it s the following: How to generate 4Billion random limited letters (not all 26) effectively to a text file so that it can be also read and modified for future use?

最佳回答

首先,如果您希望优化储存,则使用<代码>byte类型。 你们不需要改变任何东西,因为仓促可以把信件按原价值储存起来。

The best thing to do for the original save is to have a FileOutputStream and "page" the generation, for example write every 100 megabytes.

关于进一步存档,<代码>RandomAccessFile是ok。 我不想增加一条新线,因为你已经知道每个“信息单位”在案卷上的长度,增加一条新线只会重复储存空间。

Hope I could make it clear (and makes sense) :)

Tell me是怎样做的。

问题回答

因此,你可以在3个轨道上节省8个不同的价值,即这一权利。 因此,你可以将2x3比特(即8x3比特(24/8=3)的比特储存起来,而将其储存为特性仅意味着3个特性A-H(24比)。

That s a saving of 8/3, so 1.5 billion bytes would do. However, to make a short example Assuming you had to store a sequence which isn t dividable by 8, then you would have some unused bytes in you code:

页: 1 你们将如何区别于B? B仅为001,因此填满了100。

Ok. 对于1.5英镑的卷宗,你只能总是对单一星号进行补充,这告诉你,最后一个星号的轨道有多少将使用。 在上述例子中,你一收到6份,一收到3份。

但现在,如果你必须插入一些东西。 你总是通过双轨制转变,但如果没有八分五裂的插入,你只能读到以下的 by子,并将之传给你的比喻,但你必须逐字逐调:切断和平,把和平降为2个和平,把第一部分推向过大,将第二部分作为下游的超支。

执行可能不会过于trick,但我不知道操作时间会如何受到影响。

或许可以进行统计分析。 随附的特性和数量多。 如何经常在规模上插入?

也许更容易将档案整理成空白——也许有1 000份2MB的档案,每个档案中都有一个自由的缓冲,以备查阅。 最后一个字节可以说明有多少 by在档案中被视为内容。

如何添加数据? 是否“在第2号立场上插入”第713 345 947号“AHA”号顺序? 还是“在“FACHDAG”“BACH”第三序列之后插入”? 是否有典型的、经常重复的顺序,如使用自然语言的话?

首先,外部指数非常有用。 如果你可以调查,在1 000份档案中,2 713 345 947个职位是,平均而言,需要读到1.5G的50%可以大大提高速度。

但你们需要统计分析: 案卷的大小将保持不变。 它经常读写。 更新后插入、附上、删除。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签