KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > j > LocalFile


1 /*
2  * LocalFile.java
3  *
4  * Copyright (C) 2002 Peter Graves
5  * $Id: LocalFile.java,v 1.2 2002/12/08 02:18:33 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.j;
23
24 import java.net.InetAddress JavaDoc;
25 import java.net.UnknownHostException JavaDoc;
26
27 /**
28  * As it stands, LocalFile is a convenience class for accessing <code>
29  * java.io.File</code>'s separator variables.
30  *
31  * @future LocalFile should extend File and implement all of the
32  * functionality specific to local files (as opposed to remote
33  * files).
34  *
35  * @see File
36  * @see java.io.File
37  */

38 public final class LocalFile
39 {
40     private static final String JavaDoc localHostName;
41
42     static {
43         String JavaDoc name = null;
44         try {
45             InetAddress JavaDoc addr = InetAddress.getLocalHost();
46             name = addr.getHostName();
47         }
48         catch (UnknownHostException JavaDoc e) {
49             Log.error(e);
50         }
51         localHostName = name != null ? name : "local";
52     }
53
54     public static final String JavaDoc getLocalHostName()
55     {
56         return localHostName;
57     }
58
59     /**
60      * Returns the path separator character for the current platform (as a
61      * String).
62      *
63      * @return The platform-specific path separator character
64      */

65     public static final String JavaDoc getPathSeparator()
66     {
67         return java.io.File.pathSeparator;
68     }
69
70     /**
71      * Returns the path separator character for the current platform.
72      *
73      * @return The platform-specific path separator character
74      */

75     public static final char getPathSeparatorChar()
76     {
77         return java.io.File.pathSeparatorChar;
78     }
79
80     /**
81      * Returns the name separator character for the current platform (as a
82      * String).
83      *
84      * @return The platform-specific name separator character
85      */

86     public static final String JavaDoc getSeparator()
87     {
88         return java.io.File.separator;
89     }
90
91     /**
92      * Returns the name separator character for the current platform.
93      *
94      * @return The platform specific name separator character
95      */

96     public static final char getSeparatorChar()
97     {
98         return java.io.File.separatorChar;
99     }
100 }
101
Popular Tags