Click here to Skip to main content
15,902,634 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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.
Posted

1 solution

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].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900