Is there a java system property for the C: drive (or the unix equivalent)?

I have an ant build that I am trying to configure so that the generated files are deployed outside of my project folder.

The Java System properties give me access to $ {user.home}, but I have to be more specific. "Machintosh HD / Applications".

How can I point ant to a directory larger than user.home?

+4
source share
8 answers

You can just use slashes (Unix style) and just run your paths with / :

 <property name="root.dir" location="/"/> 

and it will resolve the default root of the drive that matches your OS platform (for example, C:\ on Windows and / on Unix).

 <property name="tmp.dir" location="/tmp"/> 

allow C:\tmp or /tmp , depending on your platform.

+6
source

You can use getParent()

 File f = new File(System.getProperty("user.home")); f.getParent();//this would return the parent of user home which you need. 

In your update:

 You can use [File.listRoots()][2] 
+2
source

Try a look at File.listRoots() . Combining with ANT java task can get the desired result.

+2
source

Can you use ${user.home}/../ ?

+1
source

Another interesting class is FileSystemView. It contains information about special files, such as the "Desktop" or "My Computer" node element:

  final javax.swing.filechooser.FileSystemView fileSystemView = javax.swing.filechooser.FileSystemView.getFileSystemView(); File[] roots=fileSystemView.getRoots(); 

you can use this class to check if the file is a node disk or a node floppy disk, and besides using isTraversable you can check for example. empty CD-ROM drives, i.e. existing roots for which File.listFiles () will fail.

+1
source

How to define your own variable? See here .

0
source

Use File.listRoots()

List of available file system roots.

A separate Java platform can support zero or more hierarchically organized file systems. Each file system has a root directory from which all other files in this file system can be reached. Windows platforms for example, have a root directory for each active drive; UNIX platforms have one root directory, namely "/".

The set of available file system roots depends on various system levels of operations such as inserting or ejecting removable media and disconnecting or unmounting physical or virtual disks.

0
source

Here is the code to burn the disc:

 public static void main(String[] args) { for(File drive:File.listRoots()) System.out.println(drive.getPath()); } 
0
source

All Articles