Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 java 中创建一个固定大小(5 MB)的 XML 文件。
如何制作这个文件并写入它?
写出,<a>后跟 4,999,993 个空格,后跟</a>.
<a>
</a>
最初用空格填充标签填充文件(足够等于 5MB):
<placeholder></placeholder>
当您向文件添加记录时,删除空格填充标签并替换为记录:
<rec><key>a</key><val>2</val></rec>