关于Java的澄清说明:RandomAccessFile [英] Clarification Regarding Java : RandomAccessFile

查看:71
本文介绍了关于Java的澄清说明:RandomAccessFile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我不希望在其中创建文件,则在其中创建文件之前,请先使用java.io create Directory提供的RandomAccessFile功能.

例如:

我需要创建一个名为Test.ini的文件并将一些内容插入其中,该文件将存储在C:\ Settings中.
我正在使用RandomAccessFile将内容存储在.ini文件中.

说我没有C:\ Settings目录,RandomAccessFile会创建目录并在其中创建文件吗?

预先感谢.

Will the RandomAccessFile functionality provided by the java.io create Directory before creating a file inside it, if the directory does not exist inside which i am supposed to create the file.

For eg :

I need to create a file named Test.ini and insert some content into it, and this file is to be stored in C:\Settings.
I am making use of RandomAccessFile to store the contents in .ini file.

Say i don''t have the C:\Settings directory, will the RandomAccessFile create the directory and create the file inside it ??

Thanks in advance.

推荐答案

否,这不是RandomAccessFile或Java所独有的.

0.检查文件夹是否存在,如果缺少则创建,
1.检查文件是否存在,并根据需要创建或替换.

除非您编写自己的包装程序以始终确保文件夹存在,否则这就是完成的事情" [tm].
No and this is not unique to RandomAccessFile or Java.

0. Check the folders exist and create if missing,
1. Check if the file exists and create or replace as required.

Unless you write your own wrapper to always ensure a folder exists, this is the ''done thing'' [tm].


这篇关于关于Java的澄清说明:RandomAccessFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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