KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > lang > SystemUtils


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.lang;
17
18 import java.io.File JavaDoc;
19
20 /**
21  * <p>Helpers for <code>java.lang.System</code>.</p>
22  *
23  * <p>If a system property cannot be read due to security restrictions,
24  * the corresponding field in this class will be set to <code>null</code>
25  * and a message will be written to <code>System.err</code>.</p>
26  *
27  * @author Based on code from Avalon Excalibur
28  * @author Based on code from Lucene
29  * @author Stephen Colebourne
30  * @author <a HREF="mailto:sdowney@panix.com">Steve Downey</a>
31  * @author Gary Gregory
32  * @author Michael Becke
33  * @author Tetsuya Kaneuchi
34  * @author Rafal Krupinski
35  * @author Jason Gritman
36  * @since 1.0
37  * @version $Id: SystemUtils.java 165657 2005-05-02 18:31:49Z ggregory $
38  */

39 public class SystemUtils {
40
41     /**
42      * The prefix String for all Windows OS.
43      */

44     private static final String JavaDoc OS_NAME_WINDOWS_PREFIX = "Windows";
45     
46     // System property constants
47
//-----------------------------------------------------------------------
48
// These MUST be declared first. Other constants depend on this.
49

50     /**
51      * The System property key for the user home directory.
52      */

53     private static final String JavaDoc USER_HOME_KEY = "user.home";
54
55     /**
56      * The System property key for the user directory.
57      */

58     private static final String JavaDoc USER_DIR_KEY = "user.dir";
59     
60     /**
61      * The System property key for the Java IO temporary directory.
62      */

63     private static final String JavaDoc JAVA_IO_TMPDIR_KEY = "java.io.tmpdir";
64     
65     /**
66      * The System property key for the Java home directory.
67      */

68     private static final String JavaDoc JAVA_HOME_KEY = "java.home";
69     
70     /**
71      * <p>The <code>awt.toolkit</code> System Property.</p>
72      * <p>Holds a class name, on Windows XP this is <code>sun.awt.windows.WToolkit</code>.</p>
73      * <p><b>On platforms without a GUI, this value is <code>null</code>.</b></p>
74      *
75      * <p>Defaults to <code>null</code> if the runtime does not have
76      * security access to read this property or the property does not exist.</p>
77      *
78      * <p>
79      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
80      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
81      * will be out of sync with that System property.
82      * </p>
83      *
84      * @since 2.1
85      */

86     public static final String JavaDoc AWT_TOOLKIT = getSystemProperty("awt.toolkit");
87
88     /**
89      * <p>The <code>file.encoding</code> System Property.</p>
90      * <p>File encoding, such as <code>Cp1252</code>.</p>
91      *
92      * <p>Defaults to <code>null</code> if the runtime does not have
93      * security access to read this property or the property does not exist.</p>
94      *
95      * <p>
96      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
97      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
98      * will be out of sync with that System property.
99      * </p>
100      *
101      * @since 2.0
102      * @since Java 1.2
103      */

104     public static final String JavaDoc FILE_ENCODING = getSystemProperty("file.encoding");
105
106     /**
107      * <p>The <code>file.separator</code> System Property.
108      * File separator (<code>&quot;/&quot;</code> on UNIX).</p>
109      *
110      * <p>Defaults to <code>null</code> if the runtime does not have
111      * security access to read this property or the property does not exist.</p>
112      *
113      * <p>
114      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
115      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
116      * will be out of sync with that System property.
117      * </p>
118      *
119      * @since Java 1.1
120      */

121     public static final String JavaDoc FILE_SEPARATOR = getSystemProperty("file.separator");
122
123     /**
124      * <p>The <code>java.awt.fonts</code> System Property.</p>
125      *
126      * <p>Defaults to <code>null</code> if the runtime does not have
127      * security access to read this property or the property does not exist.</p>
128      *
129      * <p>
130      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
131      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
132      * will be out of sync with that System property.
133      * </p>
134      *
135      * @since 2.1
136      */

137     public static final String JavaDoc JAVA_AWT_FONTS = getSystemProperty("java.awt.fonts");
138
139     /**
140      * <p>The <code>java.awt.graphicsenv</code> System Property.</p>
141      *
142      * <p>Defaults to <code>null</code> if the runtime does not have
143      * security access to read this property or the property does not exist.</p>
144      *
145      * <p>
146      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
147      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
148      * will be out of sync with that System property.
149      * </p>
150      *
151      * @since 2.1
152      */

153     public static final String JavaDoc JAVA_AWT_GRAPHICSENV = getSystemProperty("java.awt.graphicsenv");
154
155     /**
156      * <p>
157      * The <code>java.awt.headless</code> System Property.
158      * The value of this property is the String <code>"true"</code> or <code>"false"</code>.
159      * </p>
160      *
161      * <p>Defaults to <code>null</code> if the runtime does not have
162      * security access to read this property or the property does not exist.</p>
163      *
164      * <p>
165      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
166      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
167      * will be out of sync with that System property.
168      * </p>
169      *
170      * @see #isJavaAwtHeadless()
171      * @since 2.1
172      * @since Java 1.4
173      */

174     public static final String JavaDoc JAVA_AWT_HEADLESS = getSystemProperty("java.awt.headless");
175
176     /**
177      * <p>The <code>java.awt.printerjob</code> System Property.</p>
178      *
179      * <p>Defaults to <code>null</code> if the runtime does not have
180      * security access to read this property or the property does not exist.</p>
181      *
182      * <p>
183      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
184      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
185      * will be out of sync with that System property.
186      * </p>
187      *
188      * @since 2.1
189      */

190     public static final String JavaDoc JAVA_AWT_PRINTERJOB = getSystemProperty("java.awt.printerjob");
191
192     /**
193      * <p>The <code>java.class.path</code> System Property. Java class path.</p>
194      *
195      * <p>Defaults to <code>null</code> if the runtime does not have
196      * security access to read this property or the property does not exist.</p>
197      *
198      * <p>
199      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
200      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
201      * will be out of sync with that System property.
202      * </p>
203      *
204      * @since Java 1.1
205      */

206     public static final String JavaDoc JAVA_CLASS_PATH = getSystemProperty("java.class.path");
207
208     /**
209      * <p>The <code>java.class.version</code> System Property.
210      * Java class format version number.</p>
211      *
212      * <p>Defaults to <code>null</code> if the runtime does not have
213      * security access to read this property or the property does not exist.</p>
214      *
215      * <p>
216      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
217      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
218      * will be out of sync with that System property.
219      * </p>
220      *
221      * @since Java 1.1
222      */

223     public static final String JavaDoc JAVA_CLASS_VERSION = getSystemProperty("java.class.version");
224
225     /**
226      * <p>The <code>java.compiler</code> System Property. Name of JIT compiler to use.
227      * First in JDK version 1.2. Not used in Sun JDKs after 1.2.</p>
228      *
229      * <p>Defaults to <code>null</code> if the runtime does not have
230      * security access to read this property or the property does not exist.</p>
231      *
232      * <p>
233      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
234      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
235      * will be out of sync with that System property.
236      * </p>
237      *
238      * @since Java 1.2. Not used in Sun versions after 1.2.
239      */

240     public static final String JavaDoc JAVA_COMPILER = getSystemProperty("java.compiler");
241
242     /**
243      * <p>The <code>java.endorsed.dirs</code> System Property. Path of endorsed directory
244      * or directories.</p>
245      *
246      * <p>Defaults to <code>null</code> if the runtime does not have
247      * security access to read this property or the property does not exist.</p>
248      *
249      * <p>
250      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
251      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
252      * will be out of sync with that System property.
253      * </p>
254      *
255      * @since Java 1.4
256      */

257     public static final String JavaDoc JAVA_ENDORSED_DIRS = getSystemProperty("java.endorsed.dirs");
258
259     /**
260      * <p>The <code>java.ext.dirs</code> System Property. Path of extension directory
261      * or directories.</p>
262      *
263      * <p>Defaults to <code>null</code> if the runtime does not have
264      * security access to read this property or the property does not exist.</p>
265      *
266      * <p>
267      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
268      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
269      * will be out of sync with that System property.
270      * </p>
271      *
272      * @since Java 1.3
273      */

274     public static final String JavaDoc JAVA_EXT_DIRS = getSystemProperty("java.ext.dirs");
275
276     /**
277      * <p>The <code>java.home</code> System Property. Java installation directory.</p>
278      *
279      * <p>Defaults to <code>null</code> if the runtime does not have
280      * security access to read this property or the property does not exist.</p>
281      *
282      * <p>
283      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
284      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
285      * will be out of sync with that System property.
286      * </p>
287      *
288      * @since Java 1.1
289      */

290     public static final String JavaDoc JAVA_HOME = getSystemProperty(JAVA_HOME_KEY);
291
292     /**
293      * <p>The <code>java.io.tmpdir</code> System Property. Default temp file path.</p>
294      *
295      * <p>Defaults to <code>null</code> if the runtime does not have
296      * security access to read this property or the property does not exist.</p>
297      *
298      * <p>
299      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
300      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
301      * will be out of sync with that System property.
302      * </p>
303      *
304      * @since Java 1.2
305      */

306     public static final String JavaDoc JAVA_IO_TMPDIR = getSystemProperty(JAVA_IO_TMPDIR_KEY);
307
308     /**
309      * <p>The <code>java.library.path</code> System Property. List of paths to search
310      * when loading libraries.</p>
311      *
312      * <p>Defaults to <code>null</code> if the runtime does not have
313      * security access to read this property or the property does not exist.</p>
314      *
315      * <p>
316      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
317      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
318      * will be out of sync with that System property.
319      * </p>
320      *
321      * @since Java 1.2
322      */

323     public static final String JavaDoc JAVA_LIBRARY_PATH = getSystemProperty("java.library.path");
324
325     /**
326      * <p>The <code>java.runtime.name</code> System Property. Java Runtime Environment
327      * name.</p>
328      *
329      * <p>Defaults to <code>null</code> if the runtime does not have
330      * security access to read this property or the property does not exist.</p>
331      *
332      * <p>
333      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
334      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
335      * will be out of sync with that System property.
336      * </p>
337      *
338      * @since 2.0
339      * @since Java 1.3
340      */

341     public static final String JavaDoc JAVA_RUNTIME_NAME = getSystemProperty("java.runtime.name");
342
343     /**
344      * <p>The <code>java.runtime.version</code> System Property. Java Runtime Environment
345      * version.</p>
346      *
347      * <p>Defaults to <code>null</code> if the runtime does not have
348      * security access to read this property or the property does not exist.</p>
349      *
350      * <p>
351      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
352      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
353      * will be out of sync with that System property.
354      * </p>
355      *
356      * @since 2.0
357      * @since Java 1.3
358      */

359     public static final String JavaDoc JAVA_RUNTIME_VERSION = getSystemProperty("java.runtime.version");
360
361     /**
362      * <p>The <code>java.specification.name</code> System Property. Java Runtime Environment
363      * specification name.</p>
364      *
365      * <p>Defaults to <code>null</code> if the runtime does not have
366      * security access to read this property or the property does not exist.</p>
367      *
368      * <p>
369      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
370      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
371      * will be out of sync with that System property.
372      * </p>
373      *
374      * @since Java 1.2
375      */

376     public static final String JavaDoc JAVA_SPECIFICATION_NAME = getSystemProperty("java.specification.name");
377
378     /**
379      * <p>The <code>java.specification.vendor</code> System Property. Java Runtime Environment
380      * specification vendor.</p>
381      *
382      * <p>Defaults to <code>null</code> if the runtime does not have
383      * security access to read this property or the property does not exist.</p>
384      *
385      * <p>
386      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
387      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
388      * will be out of sync with that System property.
389      * </p>
390      *
391      * @since Java 1.2
392      */

393     public static final String JavaDoc JAVA_SPECIFICATION_VENDOR = getSystemProperty("java.specification.vendor");
394
395     /**
396      * <p>The <code>java.specification.version</code> System Property. Java Runtime Environment
397      * specification version.</p>
398      *
399      * <p>Defaults to <code>null</code> if the runtime does not have
400      * security access to read this property or the property does not exist.</p>
401      *
402      * <p>
403      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
404      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
405      * will be out of sync with that System property.
406      * </p>
407      *
408      * @since Java 1.3
409      */

410     public static final String JavaDoc JAVA_SPECIFICATION_VERSION = getSystemProperty("java.specification.version");
411
412     /**
413      * <p>The <code>java.util.prefs.PreferencesFactory</code> System Property. A class name.</p>
414      *
415      * <p>Defaults to <code>null</code> if the runtime does not have
416      * security access to read this property or the property does not exist.</p>
417      *
418      * <p>
419      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
420      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
421      * will be out of sync with that System property.
422      * </p>
423      *
424      * @since 2.1
425      * @since Java 1.4
426      */

427     public static final String JavaDoc JAVA_UTIL_PREFS_PREFERENCES_FACTORY =
428         getSystemProperty("java.util.prefs.PreferencesFactory");
429
430     /**
431      * <p>The <code>java.vendor</code> System Property. Java vendor-specific string.</p>
432      *
433      * <p>Defaults to <code>null</code> if the runtime does not have
434      * security access to read this property or the property does not exist.</p>
435      *
436      * <p>
437      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
438      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
439      * will be out of sync with that System property.
440      * </p>
441      *
442      * @since Java 1.1
443      */

444     public static final String JavaDoc JAVA_VENDOR = getSystemProperty("java.vendor");
445
446     /**
447      * <p>The <code>java.vendor.url</code> System Property. Java vendor URL.</p>
448      *
449      * <p>Defaults to <code>null</code> if the runtime does not have
450      * security access to read this property or the property does not exist.</p>
451      *
452      * <p>
453      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
454      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
455      * will be out of sync with that System property.
456      * </p>
457      *
458      * @since Java 1.1
459     */

460     public static final String JavaDoc JAVA_VENDOR_URL = getSystemProperty("java.vendor.url");
461
462     /**
463      * <p>The <code>java.version</code> System Property. Java version number.</p>
464      *
465      * <p>Defaults to <code>null</code> if the runtime does not have
466      * security access to read this property or the property does not exist.</p>
467      *
468      * <p>
469      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
470      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
471      * will be out of sync with that System property.
472      * </p>
473      *
474      * @since Java 1.1
475      */

476     public static final String JavaDoc JAVA_VERSION = getSystemProperty("java.version");
477
478     /**
479      * <p>The <code>java.vm.info</code> System Property. Java Virtual Machine implementation
480      * info.</p>
481      *
482      * <p>Defaults to <code>null</code> if the runtime does not have
483      * security access to read this property or the property does not exist.</p>
484      *
485      * <p>
486      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
487      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
488      * will be out of sync with that System property.
489      * </p>
490      *
491      * @since 2.0
492      * @since Java 1.2
493      */

494     public static final String JavaDoc JAVA_VM_INFO = getSystemProperty("java.vm.info");
495
496     /**
497      * <p>The <code>java.vm.name</code> System Property. Java Virtual Machine implementation
498      * name.</p>
499      *
500      * <p>Defaults to <code>null</code> if the runtime does not have
501      * security access to read this property or the property does not exist.</p>
502      *
503      * <p>
504      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
505      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
506      * will be out of sync with that System property.
507      * </p>
508      *
509      * @since Java 1.2
510      */

511     public static final String JavaDoc JAVA_VM_NAME = getSystemProperty("java.vm.name");
512
513     /**
514      * <p>The <code>java.vm.specification.name</code> System Property. Java Virtual Machine
515      * specification name.</p>
516      *
517      * <p>Defaults to <code>null</code> if the runtime does not have
518      * security access to read this property or the property does not exist.</p>
519      *
520      * <p>
521      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
522      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
523      * will be out of sync with that System property.
524      * </p>
525      *
526      * @since Java 1.2
527      */

528     public static final String JavaDoc JAVA_VM_SPECIFICATION_NAME = getSystemProperty("java.vm.specification.name");
529
530     /**
531      * <p>The <code>java.vm.specification.vendor</code> System Property. Java Virtual
532      * Machine specification vendor.</p>
533      *
534      * <p>Defaults to <code>null</code> if the runtime does not have
535      * security access to read this property or the property does not exist.</p>
536      *
537      * <p>
538      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
539      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
540      * will be out of sync with that System property.
541      * </p>
542      *
543      * @since Java 1.2
544      */

545     public static final String JavaDoc JAVA_VM_SPECIFICATION_VENDOR = getSystemProperty("java.vm.specification.vendor");
546
547     /**
548      * <p>The <code>java.vm.specification.version</code> System Property. Java Virtual Machine
549      * specification version.</p>
550      *
551      * <p>Defaults to <code>null</code> if the runtime does not have
552      * security access to read this property or the property does not exist.</p>
553      *
554      * <p>
555      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
556      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
557      * will be out of sync with that System property.
558      * </p>
559      *
560      * @since Java 1.2
561      */

562     public static final String JavaDoc JAVA_VM_SPECIFICATION_VERSION = getSystemProperty("java.vm.specification.version");
563
564     /**
565      * <p>The <code>java.vm.vendor</code> System Property. Java Virtual Machine implementation
566      * vendor.</p>
567      *
568      * <p>Defaults to <code>null</code> if the runtime does not have
569      * security access to read this property or the property does not exist.</p>
570      *
571      * <p>
572      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
573      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
574      * will be out of sync with that System property.
575      * </p>
576      *
577      * @since Java 1.2
578      */

579     public static final String JavaDoc JAVA_VM_VENDOR = getSystemProperty("java.vm.vendor");
580
581     /**
582      * <p>The <code>java.vm.version</code> System Property. Java Virtual Machine
583      * implementation version.</p>
584      *
585      * <p>Defaults to <code>null</code> if the runtime does not have
586      * security access to read this property or the property does not exist.</p>
587      *
588      * <p>
589      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
590      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
591      * will be out of sync with that System property.
592      * </p>
593      *
594      * @since Java 1.2
595      */

596     public static final String JavaDoc JAVA_VM_VERSION = getSystemProperty("java.vm.version");
597
598     /**
599      * <p>The <code>line.separator</code> System Property. Line separator
600      * (<code>&quot;\n&quot;</code> on UNIX).</p>
601      *
602      * <p>Defaults to <code>null</code> if the runtime does not have
603      * security access to read this property or the property does not exist.</p>
604      *
605      * <p>
606      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
607      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
608      * will be out of sync with that System property.
609      * </p>
610      *
611      * @since Java 1.1
612      */

613     public static final String JavaDoc LINE_SEPARATOR = getSystemProperty("line.separator");
614
615     /**
616      * <p>The <code>os.arch</code> System Property. Operating system architecture.</p>
617      *
618      * <p>Defaults to <code>null</code> if the runtime does not have
619      * security access to read this property or the property does not exist.</p>
620      *
621      * <p>
622      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
623      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
624      * will be out of sync with that System property.
625      * </p>
626      *
627      * @since Java 1.1
628      */

629     public static final String JavaDoc OS_ARCH = getSystemProperty("os.arch");
630
631     /**
632      * <p>The <code>os.name</code> System Property. Operating system name.</p>
633      *
634      * <p>Defaults to <code>null</code> if the runtime does not have
635      * security access to read this property or the property does not exist.</p>
636      *
637      * <p>
638      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
639      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
640      * will be out of sync with that System property.
641      * </p>
642      *
643      * @since Java 1.1
644      */

645     public static final String JavaDoc OS_NAME = getSystemProperty("os.name");
646
647     /**
648      * <p>The <code>os.version</code> System Property. Operating system version.</p>
649      *
650      * <p>Defaults to <code>null</code> if the runtime does not have
651      * security access to read this property or the property does not exist.</p>
652      *
653      * <p>
654      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
655      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
656      * will be out of sync with that System property.
657      * </p>
658      *
659      * @since Java 1.1
660      */

661     public static final String JavaDoc OS_VERSION = getSystemProperty("os.version");
662
663     /**
664      * <p>The <code>path.separator</code> System Property. Path separator
665      * (<code>&quot;:&quot;</code> on UNIX).</p>
666      *
667      * <p>Defaults to <code>null</code> if the runtime does not have
668      * security access to read this property or the property does not exist.</p>
669      *
670      * <p>
671      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
672      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
673      * will be out of sync with that System property.
674      * </p>
675      *
676      * @since Java 1.1
677      */

678     public static final String JavaDoc PATH_SEPARATOR = getSystemProperty("path.separator");
679
680     /**
681      * <p>The <code>user.country</code> or <code>user.region</code> System Property.
682      * User's country code, such as <code>GB</code>. First in JDK version 1.2 as
683      * <code>user.region</code>. Renamed to <code>user.country</code> in 1.4</p>
684      *
685      * <p>Defaults to <code>null</code> if the runtime does not have
686      * security access to read this property or the property does not exist.</p>
687      *
688      * <p>
689      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
690      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
691      * will be out of sync with that System property.
692      * </p>
693      *
694      * @since 2.0
695      * @since Java 1.2
696      */

697     public static final String JavaDoc USER_COUNTRY =
698         (getSystemProperty("user.country") == null ?
699             getSystemProperty("user.region") : getSystemProperty("user.country"));
700
701     /**
702      * <p>The <code>user.dir</code> System Property. User's current working
703      * directory.</p>
704      *
705      * <p>Defaults to <code>null</code> if the runtime does not have
706      * security access to read this property or the property does not exist.</p>
707      *
708      * <p>
709      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
710      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
711      * will be out of sync with that System property.
712      * </p>
713      *
714      * @since Java 1.1
715      */

716     public static final String JavaDoc USER_DIR = getSystemProperty(USER_DIR_KEY);
717
718     /**
719      * <p>The <code>user.home</code> System Property. User's home directory.</p>
720      *
721      * <p>Defaults to <code>null</code> if the runtime does not have
722      * security access to read this property or the property does not exist.</p>
723      *
724      * <p>
725      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
726      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
727      * will be out of sync with that System property.
728      * </p>
729      *
730      * @since Java 1.1
731      */

732     public static final String JavaDoc USER_HOME = getSystemProperty(USER_HOME_KEY);
733
734     /**
735      * <p>The <code>user.language</code> System Property. User's language code,
736      * such as <code>"en"</code>.</p>
737      *
738      * <p>Defaults to <code>null</code> if the runtime does not have
739      * security access to read this property or the property does not exist.</p>
740      *
741      * <p>
742      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
743      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
744      * will be out of sync with that System property.
745      * </p>
746      *
747      * @since 2.0
748      * @since Java 1.2
749      */

750     public static final String JavaDoc USER_LANGUAGE = getSystemProperty("user.language");
751
752     /**
753      * <p>The <code>user.name</code> System Property. User's account name.</p>
754      *
755      * <p>Defaults to <code>null</code> if the runtime does not have
756      * security access to read this property or the property does not exist.</p>
757      *
758      * <p>
759      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
760      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
761      * will be out of sync with that System property.
762      * </p>
763      *
764      * @since Java 1.1
765      */

766     public static final String JavaDoc USER_NAME = getSystemProperty("user.name");
767
768     /**
769      * <p>The <code>user.timezone</code> System Property.
770      * For example: <code>"America/Los_Angeles"</code>.</p>
771      *
772      * <p>Defaults to <code>null</code> if the runtime does not have
773      * security access to read this property or the property does not exist.</p>
774      *
775      * <p>
776      * This value is initialized when the class is loaded. If {@link System#setProperty(String,String)}
777      * or {@link System#setProperties(java.util.Properties)} is called after this class is loaded, the value
778      * will be out of sync with that System property.
779      * </p>
780      *
781      * @since 2.1
782      */

783     public static final String JavaDoc USER_TIMEZONE = getSystemProperty("user.timezone");
784
785     // Java version
786
//-----------------------------------------------------------------------
787
// This MUST be declared after those above as it depends on the
788
// values being set up
789

790     /**
791      * <p>Gets the Java version as a <code>String</code> trimming leading letters.</p>
792      *
793      * <p>The field will return <code>null</code> if {@link #JAVA_VERSION} is <code>null</code>.</p>
794      *
795      * @since 2.1
796      */

797     public static final String JavaDoc JAVA_VERSION_TRIMMED = getJavaVersionTrimmed();
798
799     // Java version values
800
//-----------------------------------------------------------------------
801
// These MUST be declared after the trim above as they depend on the
802
// value being set up
803

804     /**
805      * <p>Gets the Java version as a <code>float</code>.</p>
806      *
807      * <p>Example return values:</p>
808      * <ul>
809      * <li><code>1.2f</code> for JDK 1.2
810      * <li><code>1.31f</code> for JDK 1.3.1
811      * </ul>
812      *
813      * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
814      *
815      * @since 2.0
816      */

817     public static final float JAVA_VERSION_FLOAT = getJavaVersionAsFloat();
818
819     /**
820      * <p>Gets the Java version as an <code>int</code>.</p>
821      *
822      * <p>Example return values:</p>
823      * <ul>
824      * <li><code>120</code> for JDK 1.2
825      * <li><code>131</code> for JDK 1.3.1
826      * </ul>
827      *
828      * <p>The field will return zero if {@link #JAVA_VERSION} is <code>null</code>.</p>
829      *
830      * @since 2.0
831      */

832     public static final int JAVA_VERSION_INT = getJavaVersionAsInt();
833
834     // Java version checks
835
//-----------------------------------------------------------------------
836
// These MUST be declared after those above as they depend on the
837
// values being set up
838

839     /**
840      * <p>Is <code>true</code> if this is Java version 1.1 (also 1.1.x versions).</p>
841      *
842      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
843      * <code>null</code>.</p>
844      */

845     public static final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1");
846
847     /**
848      * <p>Is <code>true</code> if this is Java version 1.2 (also 1.2.x versions).</p>
849      *
850      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
851      * <code>null</code>.</p>
852      */

853     public static final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2");
854
855     /**
856      * <p>Is <code>true</code> if this is Java version 1.3 (also 1.3.x versions).</p>
857      *
858      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
859      * <code>null</code>.</p>
860      */

861     public static final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3");
862
863     /**
864      * <p>Is <code>true</code> if this is Java version 1.4 (also 1.4.x versions).</p>
865      *
866      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
867      * <code>null</code>.</p>
868      */

869     public static final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4");
870
871     /**
872      * <p>Is <code>true</code> if this is Java version 1.5 (also 1.5.x versions).</p>
873      *
874      * <p>The field will return <code>false</code> if {@link #JAVA_VERSION} is
875      * <code>null</code>.</p>
876      */

877     public static final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5");
878
879     // Operating system checks
880
//-----------------------------------------------------------------------
881
// These MUST be declared after those above as they depend on the
882
// values being set up
883
// OS names from http://www.vamphq.com/os.html
884
// Selected ones included - please advise commons-dev@jakarta.apache.org
885
// if you want another added or a mistake corrected
886

887     /**
888      * <p>Is <code>true</code> if this is AIX.</p>
889      *
890      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
891      * <code>null</code>.</p>
892      *
893      * @since 2.0
894      */

895     public static final boolean IS_OS_AIX = getOSMatches("AIX");
896
897     /**
898      * <p>Is <code>true</code> if this is HP-UX.</p>
899      *
900      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
901      * <code>null</code>.</p>
902      *
903      * @since 2.0
904      */

905     public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX");
906
907     /**
908      * <p>Is <code>true</code> if this is Irix.</p>
909      *
910      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
911      * <code>null</code>.</p>
912      *
913      * @since 2.0
914      */

915     public static final boolean IS_OS_IRIX = getOSMatches("Irix");
916
917     /**
918      * <p>Is <code>true</code> if this is Linux.</p>
919      *
920      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
921      * <code>null</code>.</p>
922      *
923      * @since 2.0
924      */

925     public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX");
926
927     /**
928      * <p>Is <code>true</code> if this is Mac.</p>
929      *
930      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
931      * <code>null</code>.</p>
932      *
933      * @since 2.0
934      */

935     public static final boolean IS_OS_MAC = getOSMatches("Mac");
936
937     /**
938      * <p>Is <code>true</code> if this is Mac.</p>
939      *
940      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
941      * <code>null</code>.</p>
942      *
943      * @since 2.0
944      */

945     public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X");
946
947     /**
948      * <p>Is <code>true</code> if this is OS/2.</p>
949      *
950      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
951      * <code>null</code>.</p>
952      *
953      * @since 2.0
954      */

955     public static final boolean IS_OS_OS2 = getOSMatches("OS/2");
956
957     /**
958      * <p>Is <code>true</code> if this is Solaris.</p>
959      *
960      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
961      * <code>null</code>.</p>
962      *
963      * @since 2.0
964      */

965     public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris");
966
967     /**
968      * <p>Is <code>true</code> if this is SunOS.</p>
969      *
970      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
971      * <code>null</code>.</p>
972      *
973      * @since 2.0
974      */

975     public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS");
976
977     /**
978      * <p>Is <code>true</code> if this is a POSIX compilant system,
979      * as in any of AIX, HP-UX, Irix, Linux, MacOSX, Solaris or SUN OS.</p>
980      *
981      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
982      * <code>null</code>.</p>
983      *
984      * @since 2.1
985      */

986     public static final boolean IS_OS_UNIX =
987         IS_OS_AIX || IS_OS_HP_UX || IS_OS_IRIX || IS_OS_LINUX ||
988         IS_OS_MAC_OSX || IS_OS_SOLARIS || IS_OS_SUN_OS;
989
990     /**
991      * <p>Is <code>true</code> if this is Windows.</p>
992      *
993      * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
994      * <code>null</code>.</p>
995      *
996      * @since 2.0
997      */

998     public static final boolean IS_OS_WINDOWS = getOSMatches(OS_NAME_WINDOWS_PREFIX);
999
1000    /**
1001     * <p>Is <code>true</code> if this is Windows 2000.</p>
1002     *
1003     * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
1004     * <code>null</code>.</p>
1005     *
1006     * @since 2.0
1007     */

1008    public static final boolean IS_OS_WINDOWS_2000 = getOSMatches(OS_NAME_WINDOWS_PREFIX, "5.0");
1009
1010    /**
1011     * <p>Is <code>true</code> if this is Windows 95.</p>
1012     *
1013     * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
1014     * <code>null</code>.</p>
1015     *
1016     * @since 2.0
1017     */

1018    public static final boolean IS_OS_WINDOWS_95 = getOSMatches(OS_NAME_WINDOWS_PREFIX + " 9", "4.0");
1019    // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
1020

1021    /**
1022     * <p>Is <code>true</code> if this is Windows 98.</p>
1023     *
1024     * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
1025     * <code>null</code>.</p>
1026     *
1027     * @since 2.0
1028     */

1029    public static final boolean IS_OS_WINDOWS_98 = getOSMatches(OS_NAME_WINDOWS_PREFIX + " 9", "4.1");
1030    // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
1031

1032    /**
1033     * <p>Is <code>true</code> if this is Windows ME.</p>
1034     *
1035     * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
1036     * <code>null</code>.</p>
1037     *
1038     * @since 2.0
1039     */

1040    public static final boolean IS_OS_WINDOWS_ME = getOSMatches(OS_NAME_WINDOWS_PREFIX, "4.9");
1041    // JDK 1.2 running on WindowsME may return 'Windows 95', hence the above
1042

1043    /**
1044     * <p>Is <code>true</code> if this is Windows NT.</p>
1045     *
1046     * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
1047     * <code>null</code>.</p>
1048     *
1049     * @since 2.0
1050     */

1051    public static final boolean IS_OS_WINDOWS_NT = getOSMatches(OS_NAME_WINDOWS_PREFIX + " NT");
1052    // Windows 2000 returns 'Windows 2000' but may suffer from same JDK1.2 problem
1053

1054    /**
1055     * <p>Is <code>true</code> if this is Windows XP.</p>
1056     *
1057     * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
1058     * <code>null</code>.</p>
1059     *
1060     * @since 2.0
1061     */

1062    public static final boolean IS_OS_WINDOWS_XP = getOSMatches(OS_NAME_WINDOWS_PREFIX, "5.1");
1063
1064    //-----------------------------------------------------------------------
1065
/**
1066     * <p>SystemUtils instances should NOT be constructed in standard
1067     * programming. Instead, the class should be used as
1068     * <code>SystemUtils.FILE_SEPARATOR</code>.</p>
1069     *
1070     * <p>This constructor is public to permit tools that require a JavaBean
1071     * instance to operate.</p>
1072     */

1073    public SystemUtils() {
1074        // no init.
1075
}
1076    
1077    //-----------------------------------------------------------------------
1078
/**
1079     * <p>Gets the Java version number as a <code>float</code>.</p>
1080     *
1081     * <p>Example return values:</p>
1082     * <ul>
1083     * <li><code>1.2f</code> for JDK 1.2
1084     * <li><code>1.31f</code> for JDK 1.3.1
1085     * </ul>
1086     *
1087     * @return the version, for example 1.31f for JDK 1.3.1
1088     * @deprecated Use {@link #JAVA_VERSION_FLOAT} instead.
1089     * Method will be removed in Commons Lang 3.0.
1090     */

1091    public static float getJavaVersion() {
1092        return JAVA_VERSION_FLOAT;
1093    }
1094
1095    /**
1096     * <p>Gets the Java version number as a <code>float</code>.</p>
1097     *
1098     * <p>Example return values:</p>
1099     * <ul>
1100     * <li><code>1.2f</code> for JDK 1.2
1101     * <li><code>1.31f</code> for JDK 1.3.1
1102     * </ul>
1103     *
1104     * <p>Patch releases are not reported.
1105     * Zero is returned if {@link #JAVA_VERSION_TRIMMED} is <code>null</code>.</p>
1106     *
1107     * @return the version, for example 1.31f for JDK 1.3.1
1108     */

1109    private static float getJavaVersionAsFloat() {
1110        if (JAVA_VERSION_TRIMMED == null) {
1111            return 0f;
1112        }
1113        String JavaDoc str = JAVA_VERSION_TRIMMED.substring(0, 3);
1114        if (JAVA_VERSION_TRIMMED.length() >= 5) {
1115            str = str + JAVA_VERSION_TRIMMED.substring(4, 5);
1116        }
1117        return Float.parseFloat(str);
1118    }
1119    
1120    /**
1121     * <p>Gets the Java version number as an <code>int</code>.</p>
1122     *
1123     * <p>Example return values:</p>
1124     * <ul>
1125     * <li><code>120</code> for JDK 1.2
1126     * <li><code>131</code> for JDK 1.3.1
1127     * </ul>
1128     *
1129     * <p>Patch releases are not reported.
1130     * Zero is returned if {@link #JAVA_VERSION_TRIMMED} is <code>null</code>.</p>
1131     *
1132     * @return the version, for example 131 for JDK 1.3.1
1133     */

1134    private static int getJavaVersionAsInt() {
1135        if (JAVA_VERSION_TRIMMED == null) {
1136            return 0;
1137        }
1138        String JavaDoc str = JAVA_VERSION_TRIMMED.substring(0, 1);
1139        str = str + JAVA_VERSION_TRIMMED.substring(2, 3);
1140        if (JAVA_VERSION_TRIMMED.length() >= 5) {
1141            str = str + JAVA_VERSION_TRIMMED.substring(4, 5);
1142        } else {
1143            str = str + "0";
1144        }
1145        return Integer.parseInt(str);
1146    }
1147
1148    /**
1149     * Trims the text of the java version to start with numbers.
1150     *
1151     * @return the trimmed java version
1152     */

1153    private static String JavaDoc getJavaVersionTrimmed() {
1154        if (JAVA_VERSION != null) {
1155            for (int i = 0; i < JAVA_VERSION.length(); i++) {
1156                char ch = JAVA_VERSION.charAt(i);
1157                if (ch >= '0' && ch <= '9') {
1158                    return JAVA_VERSION.substring(i);
1159                }
1160            }
1161        }
1162        return null;
1163    }
1164
1165    /**
1166     * <p>Decides if the java version matches.</p>
1167     *
1168     * @param versionPrefix the prefix for the java version
1169     * @return true if matches, or false if not or can't determine
1170     */

1171    private static boolean getJavaVersionMatches(String JavaDoc versionPrefix) {
1172        if (JAVA_VERSION_TRIMMED == null) {
1173            return false;
1174        }
1175        return JAVA_VERSION_TRIMMED.startsWith(versionPrefix);
1176    }
1177    
1178    /**
1179     * <p>Decides if the operating system matches.</p>
1180     *
1181     * @param osNamePrefix the prefix for the os name
1182     * @return true if matches, or false if not or can't determine
1183     */

1184    private static boolean getOSMatches(String JavaDoc osNamePrefix) {
1185        if (OS_NAME == null) {
1186            return false;
1187        }
1188        return OS_NAME.startsWith(osNamePrefix);
1189    }
1190
1191    /**
1192     * <p>Decides if the operating system matches.</p>
1193     *
1194     * @param osNamePrefix the prefix for the os name
1195     * @param osVersionPrefix the prefix for the version
1196     * @return true if matches, or false if not or can't determine
1197     */

1198    private static boolean getOSMatches(String JavaDoc osNamePrefix, String JavaDoc osVersionPrefix) {
1199        if (OS_NAME == null || OS_VERSION == null) {
1200            return false;
1201        }
1202        return OS_NAME.startsWith(osNamePrefix) && OS_VERSION.startsWith(osVersionPrefix);
1203    }
1204
1205    //-----------------------------------------------------------------------
1206
/**
1207     * <p>Gets a System property, defaulting to <code>null</code> if the property
1208     * cannot be read.</p>
1209     *
1210     * <p>If a <code>SecurityException</code> is caught, the return
1211     * value is <code>null</code> and a message is written to <code>System.err</code>.</p>
1212     *
1213     * @param property the system property name
1214     * @return the system property value or <code>null</code> if a security problem occurs
1215     */

1216    private static String JavaDoc getSystemProperty(String JavaDoc property) {
1217        try {
1218            return System.getProperty(property);
1219        } catch (SecurityException JavaDoc ex) {
1220            // we are not allowed to look at this property
1221
System.err.println(
1222                "Caught a SecurityException reading the system property '" + property
1223                + "'; the SystemUtils property value will default to null."
1224            );
1225            return null;
1226        }
1227    }
1228    
1229    /**
1230     * <p>Is the Java version at least the requested version.</p>
1231     *
1232     * <p>Example input:</p>
1233     * <ul>
1234     * <li><code>1.2f</code> to test for JDK 1.2</li>
1235     * <li><code>1.31f</code> to test for JDK 1.3.1</li>
1236     * </ul>
1237     *
1238     * @param requiredVersion the required version, for example 1.31f
1239     * @return <code>true</code> if the actual version is equal or greater
1240     * than the required version
1241     */

1242    public static boolean isJavaVersionAtLeast(float requiredVersion) {
1243        return JAVA_VERSION_FLOAT >= requiredVersion;
1244    }
1245    
1246    /**
1247     * <p>Is the Java version at least the requested version.</p>
1248     *
1249     * <p>Example input:</p>
1250     * <ul>
1251     * <li><code>120</code> to test for JDK 1.2 or greater</li>
1252     * <li><code>131</code> to test for JDK 1.3.1 or greater</li>
1253     * </ul>
1254     *
1255     * @param requiredVersion the required version, for example 131
1256     * @return <code>true</code> if the actual version is equal or greater
1257     * than the required version
1258     * @since 2.0
1259     */

1260    public static boolean isJavaVersionAtLeast(int requiredVersion) {
1261        return JAVA_VERSION_INT >= requiredVersion;
1262    }
1263
1264    /**
1265     * Returns whether the {@link #JAVA_AWT_HEADLESS} value is <code>true</code>.
1266     *
1267     * @return <code>true</code> if <code>JAVA_AWT_HEADLESS</code> is <code>"true"</code>,
1268     * <code>false</code> otherwise.
1269     *
1270     * @see #JAVA_AWT_HEADLESS
1271     * @since 2.1
1272     * @since Java 1.4
1273     */

1274    public static boolean isJavaAwtHeadless() {
1275        return JAVA_AWT_HEADLESS != null ? JAVA_AWT_HEADLESS.equals(Boolean.TRUE.toString()) : false;
1276    }
1277    /**
1278     * <p>Gets the Java home directory as a <code>File</code>.</p>
1279     *
1280     * @return a directory
1281     * @throws SecurityException if a security manager exists and its
1282     * <code>checkPropertyAccess</code> method doesn't allow
1283     * access to the specified system property.
1284     * @see System#getProperty(String)
1285     * @since 2.1
1286     */

1287    public static File JavaDoc getJavaHome() {
1288        return new File JavaDoc(System.getProperty(JAVA_HOME_KEY));
1289    }
1290
1291    /**
1292     * <p>Gets the Java IO temporary directory as a <code>File</code>.</p>
1293     *
1294     * @return a directory
1295     * @throws SecurityException if a security manager exists and its
1296     * <code>checkPropertyAccess</code> method doesn't allow
1297     * access to the specified system property.
1298     * @see System#getProperty(String)
1299     * @since 2.1
1300     */

1301    public static File JavaDoc getJavaIoTmpDir() {
1302        return new File JavaDoc(System.getProperty(JAVA_IO_TMPDIR_KEY));
1303    }
1304
1305    /**
1306     * <p>Gets the user directory as a <code>File</code>.</p>
1307     *
1308     * @return a directory
1309     * @throws SecurityException if a security manager exists and its
1310     * <code>checkPropertyAccess</code> method doesn't allow
1311     * access to the specified system property.
1312     * @see System#getProperty(String)
1313     * @since 2.1
1314     */

1315    public static File JavaDoc getUserDir() {
1316        return new File JavaDoc(System.getProperty(USER_DIR_KEY));
1317    }
1318
1319    /**
1320     * <p>Gets the user home directory as a <code>File</code>.</p>
1321     *
1322     * @return a directory
1323     * @throws SecurityException if a security manager exists and its
1324     * <code>checkPropertyAccess</code> method doesn't allow
1325     * access to the specified system property.
1326     * @see System#getProperty(String)
1327     * @since 2.1
1328     */

1329    public static File JavaDoc getUserHome() {
1330        return new File JavaDoc(System.getProperty(USER_HOME_KEY));
1331    }
1332
1333}
1334
Popular Tags