Bhavesh Modi
Bhavesh Modi

Reputation: 323

How to access file and directories in Linux machine using java program

I have assignment to access file system using java program. In that , I want to create file, read file modify file etc (all operation we can do on file and directory as well).

Is there any way we can do using java program / or any api available to do these operations.

Upvotes: 0

Views: 576

Answers (1)

Jordi Castilla
Jordi Castilla

Reputation: 26961

Use java.io.File and java.nio.file.Files. They don't care about which OS (Operating System) are you using. Also File wraps files and folders, check the methods File.isDirectory() and File.isFile().

NOTE: use also File.separator to standarize and avoid problems between OS

Upvotes: 1

Related Questions