01: /*
02: * LocalFile.java
03: *
04: * Copyright (C) 2002 Peter Graves
05: * $Id: LocalFile.java,v 1.2 2002/12/08 02:18:33 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * 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;
25: import java.net.UnknownHostException;
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: private static final String localHostName;
40:
41: static {
42: String name = null;
43: try {
44: InetAddress addr = InetAddress.getLocalHost();
45: name = addr.getHostName();
46: } catch (UnknownHostException e) {
47: Log.error(e);
48: }
49: localHostName = name != null ? name : "local";
50: }
51:
52: public static final String getLocalHostName() {
53: return localHostName;
54: }
55:
56: /**
57: * Returns the path separator character for the current platform (as a
58: * String).
59: *
60: * @return The platform-specific path separator character
61: */
62: public static final String getPathSeparator() {
63: return java.io.File.pathSeparator;
64: }
65:
66: /**
67: * Returns the path separator character for the current platform.
68: *
69: * @return The platform-specific path separator character
70: */
71: public static final char getPathSeparatorChar() {
72: return java.io.File.pathSeparatorChar;
73: }
74:
75: /**
76: * Returns the name separator character for the current platform (as a
77: * String).
78: *
79: * @return The platform-specific name separator character
80: */
81: public static final String getSeparator() {
82: return java.io.File.separator;
83: }
84:
85: /**
86: * Returns the name separator character for the current platform.
87: *
88: * @return The platform specific name separator character
89: */
90: public static final char getSeparatorChar() {
91: return java.io.File.separatorChar;
92: }
93: }
|