Please explain more; we can only help if we know all the details. There should not be any difference between creating a file on Windows® and on Linux; the PATHs have a different format, obviously. Tell us how you are trying to create such a file. Also find out whether the location you are trying to create it is accessible for writing or not.
are the permissions on the directory set to allow writing to the dir?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
posted 5 years ago
That is most unlikely to be accessible for writing. I suggest you change /root to a tilde and try writing it on your desktop ~/desktop/...
Please confirm whether it is desktop or Desktop; it matters on Linux.
That code needs a bit of editing. You don't need the two try blocks; apart from the names of the files they are identical. You should also close the writers in a finally (or use try‑with‑resources).
I think the "tilde" thing is a shell artifact and it won't work properly within Java program code. However there's a java.lang.System Property that returns the path of the current user's home directory. It can be used to construct an appropriate File object. Something similar to:
Note, by the way that that particular code works equally well regardless of whether it's running on Windows or on Linux.
"privilege" comes from the Latin words for "private" and "law" (legal) and dates to feudal times. To "claim privilege" meant that you were above the laws that applied to the common people.
You firghten me terribly. I would like to go home now. Here, take this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop