Source Code Cross Referenced for FileSystem.java in  » JDK-Core » io-nio » java » io » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. JDK Core
2. JDK Modules
3. JDK Modules com.sun
4. JDK Modules com.sun.java
5. JDK Modules Platform
6. JDK Modules sun
7. Open Source Build
8. Open Source Graphic Library
9. Open Source IDE Eclipse
10. Open Source J2EE
11. Open Source JDBC Driver
12. Open Source Library
13. Open Source Library Database
14. Open Source Net
15. Open Source Script
16. Science
17. Security
18. Sevlet Container
19. SUN GlassFish
20. Swing Library
21. Web Services apache cxf 2.0.1
22. Web Services AXIS2
23. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java Source Code / Java Documentation » JDK Core » io nio » java.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package java.io;
027:
028:        /**
029:         * Package-private abstract class for the local filesystem abstraction.
030:         */
031:
032:        abstract class FileSystem {
033:
034:            /**
035:             * Return the FileSystem object representing this platform's local
036:             * filesystem.
037:             */
038:            public static native FileSystem getFileSystem();
039:
040:            /* -- Normalization and construction -- */
041:
042:            /**
043:             * Return the local filesystem's name-separator character.
044:             */
045:            public abstract char getSeparator();
046:
047:            /**
048:             * Return the local filesystem's path-separator character.
049:             */
050:            public abstract char getPathSeparator();
051:
052:            /**
053:             * Convert the given pathname string to normal form.  If the string is
054:             * already in normal form then it is simply returned.
055:             */
056:            public abstract String normalize(String path);
057:
058:            /**
059:             * Compute the length of this pathname string's prefix.  The pathname
060:             * string must be in normal form.
061:             */
062:            public abstract int prefixLength(String path);
063:
064:            /**
065:             * Resolve the child pathname string against the parent.
066:             * Both strings must be in normal form, and the result
067:             * will be in normal form.
068:             */
069:            public abstract String resolve(String parent, String child);
070:
071:            /**
072:             * Return the parent pathname string to be used when the parent-directory
073:             * argument in one of the two-argument File constructors is the empty
074:             * pathname.
075:             */
076:            public abstract String getDefaultParent();
077:
078:            /**
079:             * Post-process the given URI path string if necessary.  This is used on
080:             * win32, e.g., to transform "/c:/foo" into "c:/foo".  The path string
081:             * still has slash separators; code in the File class will translate them
082:             * after this method returns.
083:             */
084:            public abstract String fromURIPath(String path);
085:
086:            /* -- Path operations -- */
087:
088:            /**
089:             * Tell whether or not the given abstract pathname is absolute.
090:             */
091:            public abstract boolean isAbsolute(File f);
092:
093:            /**
094:             * Resolve the given abstract pathname into absolute form.  Invoked by the
095:             * getAbsolutePath and getCanonicalPath methods in the File class.
096:             */
097:            public abstract String resolve(File f);
098:
099:            public abstract String canonicalize(String path) throws IOException;
100:
101:            /* -- Attribute accessors -- */
102:
103:            /* Constants for simple boolean attributes */
104:            public static final int BA_EXISTS = 0x01;
105:            public static final int BA_REGULAR = 0x02;
106:            public static final int BA_DIRECTORY = 0x04;
107:            public static final int BA_HIDDEN = 0x08;
108:
109:            /**
110:             * Return the simple boolean attributes for the file or directory denoted
111:             * by the given abstract pathname, or zero if it does not exist or some
112:             * other I/O error occurs.
113:             */
114:            public abstract int getBooleanAttributes(File f);
115:
116:            public static final int ACCESS_READ = 0x04;
117:            public static final int ACCESS_WRITE = 0x02;
118:            public static final int ACCESS_EXECUTE = 0x01;
119:
120:            /**
121:             * Check whether the file or directory denoted by the given abstract
122:             * pathname may be accessed by this process.  The second argument specifies
123:             * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check.
124:             * Return false if access is denied or an I/O error occurs
125:             */
126:            public abstract boolean checkAccess(File f, int access);
127:
128:            /**
129:             * Set on or off the access permission (to owner only or to all) to the file 
130:             * or directory denoted by the given abstract pathname, based on the parameters
131:             * enable, access and oweronly.
132:             */
133:            public abstract boolean setPermission(File f, int access,
134:                    boolean enable, boolean owneronly);
135:
136:            /**
137:             * Return the time at which the file or directory denoted by the given
138:             * abstract pathname was last modified, or zero if it does not exist or
139:             * some other I/O error occurs.
140:             */
141:            public abstract long getLastModifiedTime(File f);
142:
143:            /**
144:             * Return the length in bytes of the file denoted by the given abstract
145:             * pathname, or zero if it does not exist, is a directory, or some other
146:             * I/O error occurs.
147:             */
148:            public abstract long getLength(File f);
149:
150:            /* -- File operations -- */
151:
152:            /**
153:             * Create a new empty file with the given pathname.  Return
154:             * <code>true</code> if the file was created and <code>false</code> if a
155:             * file or directory with the given pathname already exists.  Throw an
156:             * IOException if an I/O error occurs.
157:             */
158:            public abstract boolean createFileExclusively(String pathname)
159:                    throws IOException;
160:
161:            /**
162:             * Delete the file or directory denoted by the given abstract pathname,
163:             * returning <code>true</code> if and only if the operation succeeds.
164:             */
165:            public abstract boolean delete(File f);
166:
167:            /**
168:             * List the elements of the directory denoted by the given abstract
169:             * pathname.  Return an array of strings naming the elements of the
170:             * directory if successful; otherwise, return <code>null</code>.
171:             */
172:            public abstract String[] list(File f);
173:
174:            /**
175:             * Create a new directory denoted by the given abstract pathname,
176:             * returning <code>true</code> if and only if the operation succeeds.
177:             */
178:            public abstract boolean createDirectory(File f);
179:
180:            /**
181:             * Rename the file or directory denoted by the first abstract pathname to
182:             * the second abstract pathname, returning <code>true</code> if and only if
183:             * the operation succeeds.
184:             */
185:            public abstract boolean rename(File f1, File f2);
186:
187:            /**
188:             * Set the last-modified time of the file or directory denoted by the
189:             * given abstract pathname, returning <code>true</code> if and only if the
190:             * operation succeeds.
191:             */
192:            public abstract boolean setLastModifiedTime(File f, long time);
193:
194:            /**
195:             * Mark the file or directory denoted by the given abstract pathname as
196:             * read-only, returning <code>true</code> if and only if the operation
197:             * succeeds.
198:             */
199:            public abstract boolean setReadOnly(File f);
200:
201:            /* -- Filesystem interface -- */
202:
203:            /**
204:             * List the available filesystem roots.
205:             */
206:            public abstract File[] listRoots();
207:
208:            /* -- Disk usage -- */
209:            public static final int SPACE_TOTAL = 0;
210:            public static final int SPACE_FREE = 1;
211:            public static final int SPACE_USABLE = 2;
212:
213:            public abstract long getSpace(File f, int t);
214:
215:            /* -- Basic infrastructure -- */
216:
217:            /**
218:             * Compare two abstract pathnames lexicographically.
219:             */
220:            public abstract int compare(File f1, File f2);
221:
222:            /**
223:             * Compute the hash code of an abstract pathname.
224:             */
225:            public abstract int hashCode(File f);
226:
227:            // Flags for enabling/disabling performance optimizations for file
228:            // name canonicalization
229:            static boolean useCanonCaches = true;
230:            static boolean useCanonPrefixCache = true;
231:
232:            private static boolean getBooleanProperty(String prop,
233:                    boolean defaultVal) {
234:                String val = System.getProperty(prop);
235:                if (val == null)
236:                    return defaultVal;
237:                if (val.equalsIgnoreCase("true")) {
238:                    return true;
239:                } else {
240:                    return false;
241:                }
242:            }
243:
244:            static {
245:                useCanonCaches = getBooleanProperty("sun.io.useCanonCaches",
246:                        useCanonCaches);
247:                useCanonPrefixCache = getBooleanProperty(
248:                        "sun.io.useCanonPrefixCache", useCanonPrefixCache);
249:            }
250:        }
w___w___w__.__j___a__va___2s_.__co_m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.