sedflix
sedflix

Reputation: 226

How can we create a folder and file using RandomAccessFile in a single statement?

When we write RandomAccessFile r =new RandomAccessFile("file.txt","rw");

how can I create this file in a folder named home on the desktop.. Again it should be a single statement!

Upvotes: 3

Views: 3239

Answers (1)

sedflix
sedflix

Reputation: 226

'RandomAccessFile r =new RandomAccessFile("C:/Users/Siddharth Yadav/Documents/file.txt","rw");'

RandomAccessFile r =new RandomAccessFile(path_of_file,"rw"); If file already exists then it is opened else the file is created and then opened

Upvotes: 3

Related Questions