mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-20 07:58:55 +00:00
Merge
This commit is contained in:
commit
14323dd4c7
@ -37,3 +37,4 @@ d5a1223e961891564de25c39fba6f2442d0fb045 jdk7-b57
|
||||
0c3ef2d612a47667829eb17a192decef23f1c536 jdk7-b60
|
||||
f72c0dc047b9b2e797beee68ae0b50decb1f020d jdk7-b61
|
||||
12e11fab9a839a9666a996a8f9a02fd8fa03aab6 jdk7-b62
|
||||
2ed6ed6b5bfc7dd724925b90dbb31223df59c25d jdk7-b63
|
||||
|
||||
@ -27,6 +27,7 @@ SUNWprivate_1.1 {
|
||||
global:
|
||||
Java_sun_nio_ch_SctpNet_socket0;
|
||||
Java_sun_nio_ch_SctpNet_bindx;
|
||||
Java_sun_nio_ch_SctpNet_branch0;
|
||||
Java_sun_nio_ch_SctpNet_getLocalAddresses0;
|
||||
Java_sun_nio_ch_SctpNet_getRemoteAddresses0;
|
||||
Java_sun_nio_ch_SctpNet_getPrimAddrOption0;
|
||||
|
||||
@ -97,7 +97,7 @@ else
|
||||
ifeq ($(PLATFORM), windows)
|
||||
LICENSE_DOCLIST_JDK = $(subst $(LICENSE_VERSION),,\
|
||||
$(shell $(CD) $(SHARE_JDK_DOC_SRC) && \
|
||||
$(LS) *LICENSE*$(LICENSE_VERSION)))
|
||||
$(LS) *LICENSE*$(LICENSE_VERSION)))
|
||||
LICENSE_DOCLIST_JRE = $(subst $(LICENSE_VERSION),,\
|
||||
$(shell $(CD) $(SHARE_JRE_DOC_SRC) && \
|
||||
$(LS) *LICENSE*$(LICENSE_VERSION)))
|
||||
@ -401,7 +401,7 @@ TOOLS = \
|
||||
sun/tools/jstack \
|
||||
sun/tools/jinfo \
|
||||
sun/tools/jmap
|
||||
|
||||
|
||||
# classes that go into jsse.jar
|
||||
JSSE_CLASSES_DIRS = \
|
||||
sun/security/provider/Sun.class \
|
||||
@ -645,7 +645,7 @@ $(RT_JAR_FILELIST) + $(RES_JAR_FILELIST): \
|
||||
@$(java-vm-cleanup)
|
||||
|
||||
# Create the manifest file.
|
||||
JAR_MANIFEST_FILE=$(TEMPDIR)/manifest.tmp
|
||||
JAR_MANIFEST_FILE=$(ABS_TEMPDIR)/manifest.tmp
|
||||
$(JAR_MANIFEST_FILE): $(MAINMANIFEST) $(BEANMANIFEST)
|
||||
$(prep-target)
|
||||
$(SED) -e "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST) >> $@
|
||||
@ -653,25 +653,22 @@ $(JAR_MANIFEST_FILE): $(MAINMANIFEST) $(BEANMANIFEST)
|
||||
$(CAT) $(BEANMANIFEST) >> $@
|
||||
|
||||
# Create resources.jar containing non-class files
|
||||
RESOURCES_JAR=$(TEMPDIR)/resources-orig.jar
|
||||
RES_JAR_ARGLIST=$(RES_JAR_FILELIST)_args
|
||||
$(RES_JAR_ARGLIST): $(RES_JAR_FILELIST)
|
||||
RESOURCES_JAR=$(ABS_TEMPDIR)/resources-orig.jar
|
||||
$(RESOURCES_JAR): $(RES_JAR_FILELIST) $(JAR_MANIFEST_FILE)
|
||||
$(prep-target)
|
||||
$(SED) -e "s@^@-C $(CLASSBINDIR) @" $< > $@
|
||||
$(RESOURCES_JAR): $(RES_JAR_ARGLIST) $(JAR_MANIFEST_FILE)
|
||||
$(prep-target)
|
||||
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
|
||||
@$(RES_JAR_ARGLIST) $(BOOT_JAR_JFLAGS)
|
||||
@$(java-vm-cleanup)
|
||||
$(CD) $(CLASSBINDIR) && \
|
||||
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
|
||||
@$(RES_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
|
||||
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
|
||||
|
||||
# Create jsse.jar containing SunJSSE implementation classes
|
||||
JSSE_JAR=$(TEMPDIR)/jsse-orig.jar
|
||||
JSSE_JAR=$(ABS_TEMPDIR)/jsse-orig.jar
|
||||
$(JSSE_JAR): $(JAR_MANIFEST_FILE)
|
||||
$(prep-target)
|
||||
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
|
||||
$(JSSE_CLASSES_DIRS:%=-C $(CLASSBINDIR) %) \
|
||||
$(BOOT_JAR_JFLAGS)
|
||||
@$(java-vm-cleanup)
|
||||
$(CD) $(CLASSBINDIR) && \
|
||||
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
|
||||
$(JSSE_CLASSES_DIRS) $(BOOT_JAR_JFLAGS)
|
||||
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
|
||||
|
||||
# Create sec-bin.zip
|
||||
SEC_FILES_ZIP=$(ABS_TEMPDIR)/sec-bin.zip
|
||||
@ -713,15 +710,12 @@ endif
|
||||
|
||||
# Create rt.jar
|
||||
RT_JAR=$(ABS_TEMPDIR)/rt-orig.jar
|
||||
RT_JAR_ARGLIST=$(RT_JAR_FILELIST)_args
|
||||
$(RT_JAR_ARGLIST): $(RT_JAR_FILELIST)
|
||||
$(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE)
|
||||
$(prep-target)
|
||||
$(SED) -e "s@^@-C $(CLASSBINDIR) @" $< > $@
|
||||
$(RT_JAR): $(RT_JAR_ARGLIST) $(JAR_MANIFEST_FILE)
|
||||
$(prep-target)
|
||||
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
|
||||
@$(RT_JAR_ARGLIST) $(BOOT_JAR_JFLAGS)
|
||||
@$(java-vm-cleanup)
|
||||
$(CD) $(CLASSBINDIR) && \
|
||||
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
|
||||
@$(RT_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
|
||||
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
|
||||
|
||||
# Meta-index construction to make core class loaders lazier
|
||||
|
||||
@ -949,10 +943,10 @@ initial-image-jdk:: initial-image-jdk-setup \
|
||||
@#
|
||||
@# lib/tools.jar
|
||||
@#
|
||||
$(BOOT_JAR_CMD) c0f $(LIBDIR)/tools.jar $(addprefix \
|
||||
-C $(CLASSBINDIR) , $(TOOLS)) \
|
||||
$(BOOT_JAR_JFLAGS)
|
||||
@$(java-vm-cleanup)
|
||||
$(CD) $(CLASSBINDIR) && \
|
||||
$(BOOT_JAR_CMD) c0f $(ABS_LIBDIR)/tools.jar \
|
||||
$(TOOLS) $(BOOT_JAR_JFLAGS)
|
||||
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
|
||||
$(CP) $(LIBDIR)/tools.jar $(JDK_IMAGE_DIR)/lib/tools.jar
|
||||
@#
|
||||
@# lib/ct.sym
|
||||
|
||||
@ -412,6 +412,7 @@ JAVA_JAVA_java = \
|
||||
java/io/FileReader.java \
|
||||
java/io/PipedReader.java \
|
||||
java/io/StringReader.java \
|
||||
java/io/TempFileHelper.java \
|
||||
java/io/Writer.java \
|
||||
java/io/BufferedWriter.java \
|
||||
java/io/PrintWriter.java \
|
||||
|
||||
@ -280,6 +280,9 @@ SUNWprivate_1.1 {
|
||||
Java_sun_misc_VM_initialize;
|
||||
Java_sun_misc_VMSupport_initAgentProperties;
|
||||
|
||||
# ZipFile.c needs this one
|
||||
throwFileNotFoundException;
|
||||
|
||||
# Java_sun_misc_VM_getState; threads.c
|
||||
# Java_sun_misc_VM_threadsSuspended; threads.c
|
||||
# Java_sun_misc_VM_unsuspendSomeThreads; threads.c
|
||||
|
||||
@ -86,8 +86,6 @@ FILES_src = \
|
||||
java/nio/file/CopyOption.java \
|
||||
java/nio/file/DirectoryNotEmptyException.java \
|
||||
java/nio/file/DirectoryStream.java \
|
||||
java/nio/file/DirectoryStreamFilters.java \
|
||||
java/nio/file/FileAction.java \
|
||||
java/nio/file/FileAlreadyExistsException.java \
|
||||
java/nio/file/FileRef.java \
|
||||
java/nio/file/FileStore.java \
|
||||
@ -141,6 +139,7 @@ FILES_src = \
|
||||
java/nio/file/attribute/FileStoreAttributeView.java \
|
||||
java/nio/file/attribute/FileStoreSpaceAttributeView.java \
|
||||
java/nio/file/attribute/FileStoreSpaceAttributes.java \
|
||||
java/nio/file/attribute/FileTime.java \
|
||||
java/nio/file/attribute/GroupPrincipal.java \
|
||||
java/nio/file/attribute/UserDefinedFileAttributeView.java \
|
||||
java/nio/file/attribute/PosixFileAttributeView.java \
|
||||
@ -151,7 +150,6 @@ FILES_src = \
|
||||
java/nio/file/attribute/UserPrincipalLookupService.java \
|
||||
java/nio/file/attribute/UserPrincipalNotFoundException.java \
|
||||
\
|
||||
java/nio/file/spi/AbstractPath.java \
|
||||
java/nio/file/spi/FileSystemProvider.java \
|
||||
java/nio/file/spi/FileTypeDetector.java \
|
||||
\
|
||||
@ -248,8 +246,8 @@ FILES_src = \
|
||||
\
|
||||
sun/nio/fs/AbstractAclFileAttributeView.java \
|
||||
sun/nio/fs/AbstractBasicFileAttributeView.java \
|
||||
sun/nio/fs/AbstractFileStoreSpaceAttributeView.java \
|
||||
sun/nio/fs/AbstractFileTypeDetector.java \
|
||||
sun/nio/fs/AbstractPath.java \
|
||||
sun/nio/fs/AbstractPoller.java \
|
||||
sun/nio/fs/AbstractUserDefinedFileAttributeView.java \
|
||||
sun/nio/fs/AbstractWatchKey.java \
|
||||
@ -258,12 +256,13 @@ FILES_src = \
|
||||
sun/nio/fs/Cancellable.java \
|
||||
sun/nio/fs/DefaultFileSystemProvider.java \
|
||||
sun/nio/fs/DefaultFileTypeDetector.java \
|
||||
sun/nio/fs/DynamicFileAttributeView.java \
|
||||
sun/nio/fs/FileOwnerAttributeViewImpl.java \
|
||||
sun/nio/fs/Globs.java \
|
||||
sun/nio/fs/MimeType.java \
|
||||
sun/nio/fs/NativeBuffer.java \
|
||||
sun/nio/fs/NativeBuffers.java \
|
||||
sun/nio/fs/Reflect.java \
|
||||
sun/nio/fs/Util.java \
|
||||
\
|
||||
java/net/DatagramSocket.java \
|
||||
java/net/DatagramSocketImpl.java \
|
||||
|
||||
@ -142,7 +142,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_nio_fs_LinuxNativeDispatcher_fremovexattr0;
|
||||
Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0;
|
||||
Java_sun_nio_fs_LinuxNativeDispatcher_endmntent;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_initIDs;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_init;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_strerror;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_dup;
|
||||
|
||||
@ -120,7 +120,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
|
||||
Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
|
||||
Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_initIDs;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_init;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_strerror;
|
||||
Java_sun_nio_fs_UnixNativeDispatcher_dup;
|
||||
|
||||
@ -51,6 +51,7 @@ SUNWprivate_1.1 {
|
||||
Java_java_util_zip_Inflater_reset;
|
||||
Java_java_util_zip_Inflater_setDictionary;
|
||||
Java_java_util_zip_ZipFile_close;
|
||||
Java_java_util_zip_ZipFile_getCommentBytes;
|
||||
Java_java_util_zip_ZipFile_freeEntry;
|
||||
Java_java_util_zip_ZipFile_getEntry;
|
||||
Java_java_util_zip_ZipFile_getEntryBytes;
|
||||
|
||||
@ -66,6 +66,9 @@ FILES_java = \
|
||||
sun/net/www/protocol/file/Handler.java \
|
||||
sun/net/www/protocol/file/FileURLConnection.java \
|
||||
sun/net/www/http/HttpClient.java \
|
||||
sun/net/www/http/HttpCapture.java \
|
||||
sun/net/www/http/HttpCaptureInputStream.java \
|
||||
sun/net/www/http/HttpCaptureOutputStream.java \
|
||||
sun/net/www/http/PosterOutputStream.java \
|
||||
sun/net/www/http/ChunkedInputStream.java \
|
||||
sun/net/www/http/ChunkedOutputStream.java \
|
||||
@ -75,6 +78,7 @@ FILES_java = \
|
||||
sun/net/www/http/Hurryable.java \
|
||||
sun/net/www/protocol/http/Handler.java \
|
||||
sun/net/www/protocol/http/HttpURLConnection.java \
|
||||
sun/net/www/protocol/http/HttpLogFormatter.java \
|
||||
sun/net/www/protocol/http/HttpAuthenticator.java \
|
||||
sun/net/www/protocol/http/AuthenticationHeader.java \
|
||||
sun/net/www/protocol/http/AuthenticationInfo.java \
|
||||
|
||||
@ -151,7 +151,6 @@ FILES_src = \
|
||||
sun/io/ByteToCharJISAutoDetect.java \
|
||||
sun/io/ByteToCharJohab.java \
|
||||
sun/io/ByteToCharMS874.java \
|
||||
sun/io/ByteToCharMS932DB.java \
|
||||
sun/io/ByteToCharMS932.java \
|
||||
sun/io/ByteToCharMS936.java \
|
||||
sun/io/ByteToCharMS949.java \
|
||||
@ -283,7 +282,6 @@ FILES_src = \
|
||||
sun/io/CharToByteISO8859_8.java \
|
||||
sun/io/CharToByteJohab.java \
|
||||
sun/io/CharToByteMS874.java \
|
||||
sun/io/CharToByteMS932DB.java \
|
||||
sun/io/CharToByteMS932.java \
|
||||
sun/io/CharToByteMS936.java \
|
||||
sun/io/CharToByteMS949.java \
|
||||
@ -388,7 +386,15 @@ FILES_gen_extcs = \
|
||||
sun/nio/cs/ext/IBM948.java \
|
||||
sun/nio/cs/ext/IBM949.java \
|
||||
sun/nio/cs/ext/IBM950.java \
|
||||
sun/nio/cs/ext/IBM970.java
|
||||
sun/nio/cs/ext/IBM970.java \
|
||||
sun/nio/cs/ext/EUC_CN.java \
|
||||
sun/nio/cs/ext/EUC_KR.java \
|
||||
sun/nio/cs/ext/Johab.java \
|
||||
sun/nio/cs/ext/MS932.java \
|
||||
sun/nio/cs/ext/MS936.java \
|
||||
sun/nio/cs/ext/MS949.java \
|
||||
sun/nio/cs/ext/MS950.java \
|
||||
sun/nio/cs/ext/GBK.java
|
||||
|
||||
FILES_java = $(FILES_src) $(FILES_gen_extcs)
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \
|
||||
$(install-file)
|
||||
|
||||
$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT)
|
||||
$(BOOT_JAR_CMD) cf $(CHARSETS_JAR) \
|
||||
$(BOOT_JAR_CMD) cf0 $(CHARSETS_JAR) \
|
||||
-C $(CLASSDESTDIR) sun \
|
||||
-C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \
|
||||
$(BOOT_JAR_JFLAGS)
|
||||
|
||||
7578
jdk/make/tools/CharsetMapping/EUC_CN.map
Normal file
7578
jdk/make/tools/CharsetMapping/EUC_CN.map
Normal file
File diff suppressed because it is too large
Load Diff
8365
jdk/make/tools/CharsetMapping/EUC_KR.map
Normal file
8365
jdk/make/tools/CharsetMapping/EUC_KR.map
Normal file
File diff suppressed because it is too large
Load Diff
24074
jdk/make/tools/CharsetMapping/GBK.map
Normal file
24074
jdk/make/tools/CharsetMapping/GBK.map
Normal file
File diff suppressed because it is too large
Load Diff
17196
jdk/make/tools/CharsetMapping/Johab.map
Normal file
17196
jdk/make/tools/CharsetMapping/Johab.map
Normal file
File diff suppressed because it is too large
Load Diff
21
jdk/make/tools/CharsetMapping/MS932.c2b
Normal file
21
jdk/make/tools/CharsetMapping/MS932.c2b
Normal file
@ -0,0 +1,21 @@
|
||||
#
|
||||
# (1)entries that exist only in MS932DB.c2b.private
|
||||
# (diff result of MS932DB.b2c.private and MS932DB.c2b.private)
|
||||
# (2)added the jis0201 c->b only entries
|
||||
# u+203e -> 0x7e
|
||||
# u+00a5 -> 0x5c
|
||||
#
|
||||
0x7e 0x203e
|
||||
0x5c 0x00a5
|
||||
#
|
||||
0x8143 0x00b8 # CEDILLA
|
||||
0x8145 0x00b7 # MIDDLE DOT
|
||||
0x8150 0x00af # MACRON
|
||||
0x8191 0x00a2 # CENT SIGN
|
||||
0x8192 0x00a3 # POUND SIGN
|
||||
0x81ca 0x00ac # NOT SIGN
|
||||
0x81e1 0x00ab # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x81e2 0x00bb # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
0x8394 0x3094 # HIRAGANA LETTER VU
|
||||
0x83ca 0x00b5 # MICRO SIGN
|
||||
|
||||
9809
jdk/make/tools/CharsetMapping/MS932.map
Normal file
9809
jdk/make/tools/CharsetMapping/MS932.map
Normal file
File diff suppressed because it is too large
Load Diff
402
jdk/make/tools/CharsetMapping/MS932.nr
Normal file
402
jdk/make/tools/CharsetMapping/MS932.nr
Normal file
@ -0,0 +1,402 @@
|
||||
#
|
||||
# These are the entries exist only in MS932DB.b2c.private
|
||||
# (diff result of MS932DB.b2c.private and MS932DB.c2b.private)
|
||||
#
|
||||
0x8790 0x2252 # APPROXIMATELY EQUAL TO OR THE IMAGE OF
|
||||
0x8791 0x2261 # IDENTICAL TO
|
||||
0x8792 0x222b # INTEGRAL
|
||||
0x8795 0x221a # SQUARE ROOT
|
||||
0x8796 0x22a5 # UP TACK
|
||||
0x8797 0x2220 # ANGLE
|
||||
0x879a 0x2235 # BECAUSE
|
||||
0x879b 0x2229 # INTERSECTION
|
||||
0x879c 0x222a # UNION
|
||||
0xed40 0x7e8a # CJK UNIFIED IDEOGRAPH-7E8A
|
||||
0xed41 0x891c # CJK UNIFIED IDEOGRAPH-891C
|
||||
0xed42 0x9348 # CJK UNIFIED IDEOGRAPH-9348
|
||||
0xed43 0x9288 # CJK UNIFIED IDEOGRAPH-9288
|
||||
0xed44 0x84dc # CJK UNIFIED IDEOGRAPH-84DC
|
||||
0xed45 0x4fc9 # CJK UNIFIED IDEOGRAPH-4FC9
|
||||
0xed46 0x70bb # CJK UNIFIED IDEOGRAPH-70BB
|
||||
0xed47 0x6631 # CJK UNIFIED IDEOGRAPH-6631
|
||||
0xed48 0x68c8 # CJK UNIFIED IDEOGRAPH-68C8
|
||||
0xed49 0x92f9 # CJK UNIFIED IDEOGRAPH-92F9
|
||||
0xed4a 0x66fb # CJK UNIFIED IDEOGRAPH-66FB
|
||||
0xed4b 0x5f45 # CJK UNIFIED IDEOGRAPH-5F45
|
||||
0xed4c 0x4e28 # CJK UNIFIED IDEOGRAPH-4E28
|
||||
0xed4d 0x4ee1 # CJK UNIFIED IDEOGRAPH-4EE1
|
||||
0xed4e 0x4efc # CJK UNIFIED IDEOGRAPH-4EFC
|
||||
0xed4f 0x4f00 # CJK UNIFIED IDEOGRAPH-4F00
|
||||
0xed50 0x4f03 # CJK UNIFIED IDEOGRAPH-4F03
|
||||
0xed51 0x4f39 # CJK UNIFIED IDEOGRAPH-4F39
|
||||
0xed52 0x4f56 # CJK UNIFIED IDEOGRAPH-4F56
|
||||
0xed53 0x4f92 # CJK UNIFIED IDEOGRAPH-4F92
|
||||
0xed54 0x4f8a # CJK UNIFIED IDEOGRAPH-4F8A
|
||||
0xed55 0x4f9a # CJK UNIFIED IDEOGRAPH-4F9A
|
||||
0xed56 0x4f94 # CJK UNIFIED IDEOGRAPH-4F94
|
||||
0xed57 0x4fcd # CJK UNIFIED IDEOGRAPH-4FCD
|
||||
0xed58 0x5040 # CJK UNIFIED IDEOGRAPH-5040
|
||||
0xed59 0x5022 # CJK UNIFIED IDEOGRAPH-5022
|
||||
0xed5a 0x4fff # CJK UNIFIED IDEOGRAPH-4FFF
|
||||
0xed5b 0x501e # CJK UNIFIED IDEOGRAPH-501E
|
||||
0xed5c 0x5046 # CJK UNIFIED IDEOGRAPH-5046
|
||||
0xed5d 0x5070 # CJK UNIFIED IDEOGRAPH-5070
|
||||
0xed5e 0x5042 # CJK UNIFIED IDEOGRAPH-5042
|
||||
0xed5f 0x5094 # CJK UNIFIED IDEOGRAPH-5094
|
||||
0xed60 0x50f4 # CJK UNIFIED IDEOGRAPH-50F4
|
||||
0xed61 0x50d8 # CJK UNIFIED IDEOGRAPH-50D8
|
||||
0xed62 0x514a # CJK UNIFIED IDEOGRAPH-514A
|
||||
0xed63 0x5164 # CJK UNIFIED IDEOGRAPH-5164
|
||||
0xed64 0x519d # CJK UNIFIED IDEOGRAPH-519D
|
||||
0xed65 0x51be # CJK UNIFIED IDEOGRAPH-51BE
|
||||
0xed66 0x51ec # CJK UNIFIED IDEOGRAPH-51EC
|
||||
0xed67 0x5215 # CJK UNIFIED IDEOGRAPH-5215
|
||||
0xed68 0x529c # CJK UNIFIED IDEOGRAPH-529C
|
||||
0xed69 0x52a6 # CJK UNIFIED IDEOGRAPH-52A6
|
||||
0xed6a 0x52c0 # CJK UNIFIED IDEOGRAPH-52C0
|
||||
0xed6b 0x52db # CJK UNIFIED IDEOGRAPH-52DB
|
||||
0xed6c 0x5300 # CJK UNIFIED IDEOGRAPH-5300
|
||||
0xed6d 0x5307 # CJK UNIFIED IDEOGRAPH-5307
|
||||
0xed6e 0x5324 # CJK UNIFIED IDEOGRAPH-5324
|
||||
0xed6f 0x5372 # CJK UNIFIED IDEOGRAPH-5372
|
||||
0xed70 0x5393 # CJK UNIFIED IDEOGRAPH-5393
|
||||
0xed71 0x53b2 # CJK UNIFIED IDEOGRAPH-53B2
|
||||
0xed72 0x53dd # CJK UNIFIED IDEOGRAPH-53DD
|
||||
0xed73 0xfa0e # CJK COMPATIBILITY IDEOGRAPH-FA0E
|
||||
0xed74 0x549c # CJK UNIFIED IDEOGRAPH-549C
|
||||
0xed75 0x548a # CJK UNIFIED IDEOGRAPH-548A
|
||||
0xed76 0x54a9 # CJK UNIFIED IDEOGRAPH-54A9
|
||||
0xed77 0x54ff # CJK UNIFIED IDEOGRAPH-54FF
|
||||
0xed78 0x5586 # CJK UNIFIED IDEOGRAPH-5586
|
||||
0xed79 0x5759 # CJK UNIFIED IDEOGRAPH-5759
|
||||
0xed7a 0x5765 # CJK UNIFIED IDEOGRAPH-5765
|
||||
0xed7b 0x57ac # CJK UNIFIED IDEOGRAPH-57AC
|
||||
0xed7c 0x57c8 # CJK UNIFIED IDEOGRAPH-57C8
|
||||
0xed7d 0x57c7 # CJK UNIFIED IDEOGRAPH-57C7
|
||||
0xed7e 0xfa0f # CJK COMPATIBILITY IDEOGRAPH-FA0F
|
||||
0xed80 0xfa10 # CJK COMPATIBILITY IDEOGRAPH-FA10
|
||||
0xed81 0x589e # CJK UNIFIED IDEOGRAPH-589E
|
||||
0xed82 0x58b2 # CJK UNIFIED IDEOGRAPH-58B2
|
||||
0xed83 0x590b # CJK UNIFIED IDEOGRAPH-590B
|
||||
0xed84 0x5953 # CJK UNIFIED IDEOGRAPH-5953
|
||||
0xed85 0x595b # CJK UNIFIED IDEOGRAPH-595B
|
||||
0xed86 0x595d # CJK UNIFIED IDEOGRAPH-595D
|
||||
0xed87 0x5963 # CJK UNIFIED IDEOGRAPH-5963
|
||||
0xed88 0x59a4 # CJK UNIFIED IDEOGRAPH-59A4
|
||||
0xed89 0x59ba # CJK UNIFIED IDEOGRAPH-59BA
|
||||
0xed8a 0x5b56 # CJK UNIFIED IDEOGRAPH-5B56
|
||||
0xed8b 0x5bc0 # CJK UNIFIED IDEOGRAPH-5BC0
|
||||
0xed8c 0x752f # CJK UNIFIED IDEOGRAPH-752F
|
||||
0xed8d 0x5bd8 # CJK UNIFIED IDEOGRAPH-5BD8
|
||||
0xed8e 0x5bec # CJK UNIFIED IDEOGRAPH-5BEC
|
||||
0xed8f 0x5c1e # CJK UNIFIED IDEOGRAPH-5C1E
|
||||
0xed90 0x5ca6 # CJK UNIFIED IDEOGRAPH-5CA6
|
||||
0xed91 0x5cba # CJK UNIFIED IDEOGRAPH-5CBA
|
||||
0xed92 0x5cf5 # CJK UNIFIED IDEOGRAPH-5CF5
|
||||
0xed93 0x5d27 # CJK UNIFIED IDEOGRAPH-5D27
|
||||
0xed94 0x5d53 # CJK UNIFIED IDEOGRAPH-5D53
|
||||
0xed95 0xfa11 # CJK COMPATIBILITY IDEOGRAPH-FA11
|
||||
0xed96 0x5d42 # CJK UNIFIED IDEOGRAPH-5D42
|
||||
0xed97 0x5d6d # CJK UNIFIED IDEOGRAPH-5D6D
|
||||
0xed98 0x5db8 # CJK UNIFIED IDEOGRAPH-5DB8
|
||||
0xed99 0x5db9 # CJK UNIFIED IDEOGRAPH-5DB9
|
||||
0xed9a 0x5dd0 # CJK UNIFIED IDEOGRAPH-5DD0
|
||||
0xed9b 0x5f21 # CJK UNIFIED IDEOGRAPH-5F21
|
||||
0xed9c 0x5f34 # CJK UNIFIED IDEOGRAPH-5F34
|
||||
0xed9d 0x5f67 # CJK UNIFIED IDEOGRAPH-5F67
|
||||
0xed9e 0x5fb7 # CJK UNIFIED IDEOGRAPH-5FB7
|
||||
0xed9f 0x5fde # CJK UNIFIED IDEOGRAPH-5FDE
|
||||
0xeda0 0x605d # CJK UNIFIED IDEOGRAPH-605D
|
||||
0xeda1 0x6085 # CJK UNIFIED IDEOGRAPH-6085
|
||||
0xeda2 0x608a # CJK UNIFIED IDEOGRAPH-608A
|
||||
0xeda3 0x60de # CJK UNIFIED IDEOGRAPH-60DE
|
||||
0xeda4 0x60d5 # CJK UNIFIED IDEOGRAPH-60D5
|
||||
0xeda5 0x6120 # CJK UNIFIED IDEOGRAPH-6120
|
||||
0xeda6 0x60f2 # CJK UNIFIED IDEOGRAPH-60F2
|
||||
0xeda7 0x6111 # CJK UNIFIED IDEOGRAPH-6111
|
||||
0xeda8 0x6137 # CJK UNIFIED IDEOGRAPH-6137
|
||||
0xeda9 0x6130 # CJK UNIFIED IDEOGRAPH-6130
|
||||
0xedaa 0x6198 # CJK UNIFIED IDEOGRAPH-6198
|
||||
0xedab 0x6213 # CJK UNIFIED IDEOGRAPH-6213
|
||||
0xedac 0x62a6 # CJK UNIFIED IDEOGRAPH-62A6
|
||||
0xedad 0x63f5 # CJK UNIFIED IDEOGRAPH-63F5
|
||||
0xedae 0x6460 # CJK UNIFIED IDEOGRAPH-6460
|
||||
0xedaf 0x649d # CJK UNIFIED IDEOGRAPH-649D
|
||||
0xedb0 0x64ce # CJK UNIFIED IDEOGRAPH-64CE
|
||||
0xedb1 0x654e # CJK UNIFIED IDEOGRAPH-654E
|
||||
0xedb2 0x6600 # CJK UNIFIED IDEOGRAPH-6600
|
||||
0xedb3 0x6615 # CJK UNIFIED IDEOGRAPH-6615
|
||||
0xedb4 0x663b # CJK UNIFIED IDEOGRAPH-663B
|
||||
0xedb5 0x6609 # CJK UNIFIED IDEOGRAPH-6609
|
||||
0xedb6 0x662e # CJK UNIFIED IDEOGRAPH-662E
|
||||
0xedb7 0x661e # CJK UNIFIED IDEOGRAPH-661E
|
||||
0xedb8 0x6624 # CJK UNIFIED IDEOGRAPH-6624
|
||||
0xedb9 0x6665 # CJK UNIFIED IDEOGRAPH-6665
|
||||
0xedba 0x6657 # CJK UNIFIED IDEOGRAPH-6657
|
||||
0xedbb 0x6659 # CJK UNIFIED IDEOGRAPH-6659
|
||||
0xedbc 0xfa12 # CJK COMPATIBILITY IDEOGRAPH-FA12
|
||||
0xedbd 0x6673 # CJK UNIFIED IDEOGRAPH-6673
|
||||
0xedbe 0x6699 # CJK UNIFIED IDEOGRAPH-6699
|
||||
0xedbf 0x66a0 # CJK UNIFIED IDEOGRAPH-66A0
|
||||
0xedc0 0x66b2 # CJK UNIFIED IDEOGRAPH-66B2
|
||||
0xedc1 0x66bf # CJK UNIFIED IDEOGRAPH-66BF
|
||||
0xedc2 0x66fa # CJK UNIFIED IDEOGRAPH-66FA
|
||||
0xedc3 0x670e # CJK UNIFIED IDEOGRAPH-670E
|
||||
0xedc4 0xf929 # CJK COMPATIBILITY IDEOGRAPH-F929
|
||||
0xedc5 0x6766 # CJK UNIFIED IDEOGRAPH-6766
|
||||
0xedc6 0x67bb # CJK UNIFIED IDEOGRAPH-67BB
|
||||
0xedc7 0x6852 # CJK UNIFIED IDEOGRAPH-6852
|
||||
0xedc8 0x67c0 # CJK UNIFIED IDEOGRAPH-67C0
|
||||
0xedc9 0x6801 # CJK UNIFIED IDEOGRAPH-6801
|
||||
0xedca 0x6844 # CJK UNIFIED IDEOGRAPH-6844
|
||||
0xedcb 0x68cf # CJK UNIFIED IDEOGRAPH-68CF
|
||||
0xedcc 0xfa13 # CJK COMPATIBILITY IDEOGRAPH-FA13
|
||||
0xedcd 0x6968 # CJK UNIFIED IDEOGRAPH-6968
|
||||
0xedce 0xfa14 # CJK COMPATIBILITY IDEOGRAPH-FA14
|
||||
0xedcf 0x6998 # CJK UNIFIED IDEOGRAPH-6998
|
||||
0xedd0 0x69e2 # CJK UNIFIED IDEOGRAPH-69E2
|
||||
0xedd1 0x6a30 # CJK UNIFIED IDEOGRAPH-6A30
|
||||
0xedd2 0x6a6b # CJK UNIFIED IDEOGRAPH-6A6B
|
||||
0xedd3 0x6a46 # CJK UNIFIED IDEOGRAPH-6A46
|
||||
0xedd4 0x6a73 # CJK UNIFIED IDEOGRAPH-6A73
|
||||
0xedd5 0x6a7e # CJK UNIFIED IDEOGRAPH-6A7E
|
||||
0xedd6 0x6ae2 # CJK UNIFIED IDEOGRAPH-6AE2
|
||||
0xedd7 0x6ae4 # CJK UNIFIED IDEOGRAPH-6AE4
|
||||
0xedd8 0x6bd6 # CJK UNIFIED IDEOGRAPH-6BD6
|
||||
0xedd9 0x6c3f # CJK UNIFIED IDEOGRAPH-6C3F
|
||||
0xedda 0x6c5c # CJK UNIFIED IDEOGRAPH-6C5C
|
||||
0xeddb 0x6c86 # CJK UNIFIED IDEOGRAPH-6C86
|
||||
0xeddc 0x6c6f # CJK UNIFIED IDEOGRAPH-6C6F
|
||||
0xeddd 0x6cda # CJK UNIFIED IDEOGRAPH-6CDA
|
||||
0xedde 0x6d04 # CJK UNIFIED IDEOGRAPH-6D04
|
||||
0xeddf 0x6d87 # CJK UNIFIED IDEOGRAPH-6D87
|
||||
0xede0 0x6d6f # CJK UNIFIED IDEOGRAPH-6D6F
|
||||
0xede1 0x6d96 # CJK UNIFIED IDEOGRAPH-6D96
|
||||
0xede2 0x6dac # CJK UNIFIED IDEOGRAPH-6DAC
|
||||
0xede3 0x6dcf # CJK UNIFIED IDEOGRAPH-6DCF
|
||||
0xede4 0x6df8 # CJK UNIFIED IDEOGRAPH-6DF8
|
||||
0xede5 0x6df2 # CJK UNIFIED IDEOGRAPH-6DF2
|
||||
0xede6 0x6dfc # CJK UNIFIED IDEOGRAPH-6DFC
|
||||
0xede7 0x6e39 # CJK UNIFIED IDEOGRAPH-6E39
|
||||
0xede8 0x6e5c # CJK UNIFIED IDEOGRAPH-6E5C
|
||||
0xede9 0x6e27 # CJK UNIFIED IDEOGRAPH-6E27
|
||||
0xedea 0x6e3c # CJK UNIFIED IDEOGRAPH-6E3C
|
||||
0xedeb 0x6ebf # CJK UNIFIED IDEOGRAPH-6EBF
|
||||
0xedec 0x6f88 # CJK UNIFIED IDEOGRAPH-6F88
|
||||
0xeded 0x6fb5 # CJK UNIFIED IDEOGRAPH-6FB5
|
||||
0xedee 0x6ff5 # CJK UNIFIED IDEOGRAPH-6FF5
|
||||
0xedef 0x7005 # CJK UNIFIED IDEOGRAPH-7005
|
||||
0xedf0 0x7007 # CJK UNIFIED IDEOGRAPH-7007
|
||||
0xedf1 0x7028 # CJK UNIFIED IDEOGRAPH-7028
|
||||
0xedf2 0x7085 # CJK UNIFIED IDEOGRAPH-7085
|
||||
0xedf3 0x70ab # CJK UNIFIED IDEOGRAPH-70AB
|
||||
0xedf4 0x710f # CJK UNIFIED IDEOGRAPH-710F
|
||||
0xedf5 0x7104 # CJK UNIFIED IDEOGRAPH-7104
|
||||
0xedf6 0x715c # CJK UNIFIED IDEOGRAPH-715C
|
||||
0xedf7 0x7146 # CJK UNIFIED IDEOGRAPH-7146
|
||||
0xedf8 0x7147 # CJK UNIFIED IDEOGRAPH-7147
|
||||
0xedf9 0xfa15 # CJK COMPATIBILITY IDEOGRAPH-FA15
|
||||
0xedfa 0x71c1 # CJK UNIFIED IDEOGRAPH-71C1
|
||||
0xedfb 0x71fe # CJK UNIFIED IDEOGRAPH-71FE
|
||||
0xedfc 0x72b1 # CJK UNIFIED IDEOGRAPH-72B1
|
||||
0xee40 0x72be # CJK UNIFIED IDEOGRAPH-72BE
|
||||
0xee41 0x7324 # CJK UNIFIED IDEOGRAPH-7324
|
||||
0xee42 0xfa16 # CJK COMPATIBILITY IDEOGRAPH-FA16
|
||||
0xee43 0x7377 # CJK UNIFIED IDEOGRAPH-7377
|
||||
0xee44 0x73bd # CJK UNIFIED IDEOGRAPH-73BD
|
||||
0xee45 0x73c9 # CJK UNIFIED IDEOGRAPH-73C9
|
||||
0xee46 0x73d6 # CJK UNIFIED IDEOGRAPH-73D6
|
||||
0xee47 0x73e3 # CJK UNIFIED IDEOGRAPH-73E3
|
||||
0xee48 0x73d2 # CJK UNIFIED IDEOGRAPH-73D2
|
||||
0xee49 0x7407 # CJK UNIFIED IDEOGRAPH-7407
|
||||
0xee4a 0x73f5 # CJK UNIFIED IDEOGRAPH-73F5
|
||||
0xee4b 0x7426 # CJK UNIFIED IDEOGRAPH-7426
|
||||
0xee4c 0x742a # CJK UNIFIED IDEOGRAPH-742A
|
||||
0xee4d 0x7429 # CJK UNIFIED IDEOGRAPH-7429
|
||||
0xee4e 0x742e # CJK UNIFIED IDEOGRAPH-742E
|
||||
0xee4f 0x7462 # CJK UNIFIED IDEOGRAPH-7462
|
||||
0xee50 0x7489 # CJK UNIFIED IDEOGRAPH-7489
|
||||
0xee51 0x749f # CJK UNIFIED IDEOGRAPH-749F
|
||||
0xee52 0x7501 # CJK UNIFIED IDEOGRAPH-7501
|
||||
0xee53 0x756f # CJK UNIFIED IDEOGRAPH-756F
|
||||
0xee54 0x7682 # CJK UNIFIED IDEOGRAPH-7682
|
||||
0xee55 0x769c # CJK UNIFIED IDEOGRAPH-769C
|
||||
0xee56 0x769e # CJK UNIFIED IDEOGRAPH-769E
|
||||
0xee57 0x769b # CJK UNIFIED IDEOGRAPH-769B
|
||||
0xee58 0x76a6 # CJK UNIFIED IDEOGRAPH-76A6
|
||||
0xee59 0xfa17 # CJK COMPATIBILITY IDEOGRAPH-FA17
|
||||
0xee5a 0x7746 # CJK UNIFIED IDEOGRAPH-7746
|
||||
0xee5b 0x52af # CJK UNIFIED IDEOGRAPH-52AF
|
||||
0xee5c 0x7821 # CJK UNIFIED IDEOGRAPH-7821
|
||||
0xee5d 0x784e # CJK UNIFIED IDEOGRAPH-784E
|
||||
0xee5e 0x7864 # CJK UNIFIED IDEOGRAPH-7864
|
||||
0xee5f 0x787a # CJK UNIFIED IDEOGRAPH-787A
|
||||
0xee60 0x7930 # CJK UNIFIED IDEOGRAPH-7930
|
||||
0xee61 0xfa18 # CJK COMPATIBILITY IDEOGRAPH-FA18
|
||||
0xee62 0xfa19 # CJK COMPATIBILITY IDEOGRAPH-FA19
|
||||
0xee63 0xfa1a # CJK COMPATIBILITY IDEOGRAPH-FA1A
|
||||
0xee64 0x7994 # CJK UNIFIED IDEOGRAPH-7994
|
||||
0xee65 0xfa1b # CJK COMPATIBILITY IDEOGRAPH-FA1B
|
||||
0xee66 0x799b # CJK UNIFIED IDEOGRAPH-799B
|
||||
0xee67 0x7ad1 # CJK UNIFIED IDEOGRAPH-7AD1
|
||||
0xee68 0x7ae7 # CJK UNIFIED IDEOGRAPH-7AE7
|
||||
0xee69 0xfa1c # CJK COMPATIBILITY IDEOGRAPH-FA1C
|
||||
0xee6a 0x7aeb # CJK UNIFIED IDEOGRAPH-7AEB
|
||||
0xee6b 0x7b9e # CJK UNIFIED IDEOGRAPH-7B9E
|
||||
0xee6c 0xfa1d # CJK COMPATIBILITY IDEOGRAPH-FA1D
|
||||
0xee6d 0x7d48 # CJK UNIFIED IDEOGRAPH-7D48
|
||||
0xee6e 0x7d5c # CJK UNIFIED IDEOGRAPH-7D5C
|
||||
0xee6f 0x7db7 # CJK UNIFIED IDEOGRAPH-7DB7
|
||||
0xee70 0x7da0 # CJK UNIFIED IDEOGRAPH-7DA0
|
||||
0xee71 0x7dd6 # CJK UNIFIED IDEOGRAPH-7DD6
|
||||
0xee72 0x7e52 # CJK UNIFIED IDEOGRAPH-7E52
|
||||
0xee73 0x7f47 # CJK UNIFIED IDEOGRAPH-7F47
|
||||
0xee74 0x7fa1 # CJK UNIFIED IDEOGRAPH-7FA1
|
||||
0xee75 0xfa1e # CJK COMPATIBILITY IDEOGRAPH-FA1E
|
||||
0xee76 0x8301 # CJK UNIFIED IDEOGRAPH-8301
|
||||
0xee77 0x8362 # CJK UNIFIED IDEOGRAPH-8362
|
||||
0xee78 0x837f # CJK UNIFIED IDEOGRAPH-837F
|
||||
0xee79 0x83c7 # CJK UNIFIED IDEOGRAPH-83C7
|
||||
0xee7a 0x83f6 # CJK UNIFIED IDEOGRAPH-83F6
|
||||
0xee7b 0x8448 # CJK UNIFIED IDEOGRAPH-8448
|
||||
0xee7c 0x84b4 # CJK UNIFIED IDEOGRAPH-84B4
|
||||
0xee7d 0x8553 # CJK UNIFIED IDEOGRAPH-8553
|
||||
0xee7e 0x8559 # CJK UNIFIED IDEOGRAPH-8559
|
||||
0xee80 0x856b # CJK UNIFIED IDEOGRAPH-856B
|
||||
0xee81 0xfa1f # CJK COMPATIBILITY IDEOGRAPH-FA1F
|
||||
0xee82 0x85b0 # CJK UNIFIED IDEOGRAPH-85B0
|
||||
0xee83 0xfa20 # CJK COMPATIBILITY IDEOGRAPH-FA20
|
||||
0xee84 0xfa21 # CJK COMPATIBILITY IDEOGRAPH-FA21
|
||||
0xee85 0x8807 # CJK UNIFIED IDEOGRAPH-8807
|
||||
0xee86 0x88f5 # CJK UNIFIED IDEOGRAPH-88F5
|
||||
0xee87 0x8a12 # CJK UNIFIED IDEOGRAPH-8A12
|
||||
0xee88 0x8a37 # CJK UNIFIED IDEOGRAPH-8A37
|
||||
0xee89 0x8a79 # CJK UNIFIED IDEOGRAPH-8A79
|
||||
0xee8a 0x8aa7 # CJK UNIFIED IDEOGRAPH-8AA7
|
||||
0xee8b 0x8abe # CJK UNIFIED IDEOGRAPH-8ABE
|
||||
0xee8c 0x8adf # CJK UNIFIED IDEOGRAPH-8ADF
|
||||
0xee8d 0xfa22 # CJK COMPATIBILITY IDEOGRAPH-FA22
|
||||
0xee8e 0x8af6 # CJK UNIFIED IDEOGRAPH-8AF6
|
||||
0xee8f 0x8b53 # CJK UNIFIED IDEOGRAPH-8B53
|
||||
0xee90 0x8b7f # CJK UNIFIED IDEOGRAPH-8B7F
|
||||
0xee91 0x8cf0 # CJK UNIFIED IDEOGRAPH-8CF0
|
||||
0xee92 0x8cf4 # CJK UNIFIED IDEOGRAPH-8CF4
|
||||
0xee93 0x8d12 # CJK UNIFIED IDEOGRAPH-8D12
|
||||
0xee94 0x8d76 # CJK UNIFIED IDEOGRAPH-8D76
|
||||
0xee95 0xfa23 # CJK COMPATIBILITY IDEOGRAPH-FA23
|
||||
0xee96 0x8ecf # CJK UNIFIED IDEOGRAPH-8ECF
|
||||
0xee97 0xfa24 # CJK COMPATIBILITY IDEOGRAPH-FA24
|
||||
0xee98 0xfa25 # CJK COMPATIBILITY IDEOGRAPH-FA25
|
||||
0xee99 0x9067 # CJK UNIFIED IDEOGRAPH-9067
|
||||
0xee9a 0x90de # CJK UNIFIED IDEOGRAPH-90DE
|
||||
0xee9b 0xfa26 # CJK COMPATIBILITY IDEOGRAPH-FA26
|
||||
0xee9c 0x9115 # CJK UNIFIED IDEOGRAPH-9115
|
||||
0xee9d 0x9127 # CJK UNIFIED IDEOGRAPH-9127
|
||||
0xee9e 0x91da # CJK UNIFIED IDEOGRAPH-91DA
|
||||
0xee9f 0x91d7 # CJK UNIFIED IDEOGRAPH-91D7
|
||||
0xeea0 0x91de # CJK UNIFIED IDEOGRAPH-91DE
|
||||
0xeea1 0x91ed # CJK UNIFIED IDEOGRAPH-91ED
|
||||
0xeea2 0x91ee # CJK UNIFIED IDEOGRAPH-91EE
|
||||
0xeea3 0x91e4 # CJK UNIFIED IDEOGRAPH-91E4
|
||||
0xeea4 0x91e5 # CJK UNIFIED IDEOGRAPH-91E5
|
||||
0xeea5 0x9206 # CJK UNIFIED IDEOGRAPH-9206
|
||||
0xeea6 0x9210 # CJK UNIFIED IDEOGRAPH-9210
|
||||
0xeea7 0x920a # CJK UNIFIED IDEOGRAPH-920A
|
||||
0xeea8 0x923a # CJK UNIFIED IDEOGRAPH-923A
|
||||
0xeea9 0x9240 # CJK UNIFIED IDEOGRAPH-9240
|
||||
0xeeaa 0x923c # CJK UNIFIED IDEOGRAPH-923C
|
||||
0xeeab 0x924e # CJK UNIFIED IDEOGRAPH-924E
|
||||
0xeeac 0x9259 # CJK UNIFIED IDEOGRAPH-9259
|
||||
0xeead 0x9251 # CJK UNIFIED IDEOGRAPH-9251
|
||||
0xeeae 0x9239 # CJK UNIFIED IDEOGRAPH-9239
|
||||
0xeeaf 0x9267 # CJK UNIFIED IDEOGRAPH-9267
|
||||
0xeeb0 0x92a7 # CJK UNIFIED IDEOGRAPH-92A7
|
||||
0xeeb1 0x9277 # CJK UNIFIED IDEOGRAPH-9277
|
||||
0xeeb2 0x9278 # CJK UNIFIED IDEOGRAPH-9278
|
||||
0xeeb3 0x92e7 # CJK UNIFIED IDEOGRAPH-92E7
|
||||
0xeeb4 0x92d7 # CJK UNIFIED IDEOGRAPH-92D7
|
||||
0xeeb5 0x92d9 # CJK UNIFIED IDEOGRAPH-92D9
|
||||
0xeeb6 0x92d0 # CJK UNIFIED IDEOGRAPH-92D0
|
||||
0xeeb7 0xfa27 # CJK COMPATIBILITY IDEOGRAPH-FA27
|
||||
0xeeb8 0x92d5 # CJK UNIFIED IDEOGRAPH-92D5
|
||||
0xeeb9 0x92e0 # CJK UNIFIED IDEOGRAPH-92E0
|
||||
0xeeba 0x92d3 # CJK UNIFIED IDEOGRAPH-92D3
|
||||
0xeebb 0x9325 # CJK UNIFIED IDEOGRAPH-9325
|
||||
0xeebc 0x9321 # CJK UNIFIED IDEOGRAPH-9321
|
||||
0xeebd 0x92fb # CJK UNIFIED IDEOGRAPH-92FB
|
||||
0xeebe 0xfa28 # CJK COMPATIBILITY IDEOGRAPH-FA28
|
||||
0xeebf 0x931e # CJK UNIFIED IDEOGRAPH-931E
|
||||
0xeec0 0x92ff # CJK UNIFIED IDEOGRAPH-92FF
|
||||
0xeec1 0x931d # CJK UNIFIED IDEOGRAPH-931D
|
||||
0xeec2 0x9302 # CJK UNIFIED IDEOGRAPH-9302
|
||||
0xeec3 0x9370 # CJK UNIFIED IDEOGRAPH-9370
|
||||
0xeec4 0x9357 # CJK UNIFIED IDEOGRAPH-9357
|
||||
0xeec5 0x93a4 # CJK UNIFIED IDEOGRAPH-93A4
|
||||
0xeec6 0x93c6 # CJK UNIFIED IDEOGRAPH-93C6
|
||||
0xeec7 0x93de # CJK UNIFIED IDEOGRAPH-93DE
|
||||
0xeec8 0x93f8 # CJK UNIFIED IDEOGRAPH-93F8
|
||||
0xeec9 0x9431 # CJK UNIFIED IDEOGRAPH-9431
|
||||
0xeeca 0x9445 # CJK UNIFIED IDEOGRAPH-9445
|
||||
0xeecb 0x9448 # CJK UNIFIED IDEOGRAPH-9448
|
||||
0xeecc 0x9592 # CJK UNIFIED IDEOGRAPH-9592
|
||||
0xeecd 0xf9dc # CJK COMPATIBILITY IDEOGRAPH-F9DC
|
||||
0xeece 0xfa29 # CJK COMPATIBILITY IDEOGRAPH-FA29
|
||||
0xeecf 0x969d # CJK UNIFIED IDEOGRAPH-969D
|
||||
0xeed0 0x96af # CJK UNIFIED IDEOGRAPH-96AF
|
||||
0xeed1 0x9733 # CJK UNIFIED IDEOGRAPH-9733
|
||||
0xeed2 0x973b # CJK UNIFIED IDEOGRAPH-973B
|
||||
0xeed3 0x9743 # CJK UNIFIED IDEOGRAPH-9743
|
||||
0xeed4 0x974d # CJK UNIFIED IDEOGRAPH-974D
|
||||
0xeed5 0x974f # CJK UNIFIED IDEOGRAPH-974F
|
||||
0xeed6 0x9751 # CJK UNIFIED IDEOGRAPH-9751
|
||||
0xeed7 0x9755 # CJK UNIFIED IDEOGRAPH-9755
|
||||
0xeed8 0x9857 # CJK UNIFIED IDEOGRAPH-9857
|
||||
0xeed9 0x9865 # CJK UNIFIED IDEOGRAPH-9865
|
||||
0xeeda 0xfa2a # CJK COMPATIBILITY IDEOGRAPH-FA2A
|
||||
0xeedb 0xfa2b # CJK COMPATIBILITY IDEOGRAPH-FA2B
|
||||
0xeedc 0x9927 # CJK UNIFIED IDEOGRAPH-9927
|
||||
0xeedd 0xfa2c # CJK COMPATIBILITY IDEOGRAPH-FA2C
|
||||
0xeede 0x999e # CJK UNIFIED IDEOGRAPH-999E
|
||||
0xeedf 0x9a4e # CJK UNIFIED IDEOGRAPH-9A4E
|
||||
0xeee0 0x9ad9 # CJK UNIFIED IDEOGRAPH-9AD9
|
||||
0xeee1 0x9adc # CJK UNIFIED IDEOGRAPH-9ADC
|
||||
0xeee2 0x9b75 # CJK UNIFIED IDEOGRAPH-9B75
|
||||
0xeee3 0x9b72 # CJK UNIFIED IDEOGRAPH-9B72
|
||||
0xeee4 0x9b8f # CJK UNIFIED IDEOGRAPH-9B8F
|
||||
0xeee5 0x9bb1 # CJK UNIFIED IDEOGRAPH-9BB1
|
||||
0xeee6 0x9bbb # CJK UNIFIED IDEOGRAPH-9BBB
|
||||
0xeee7 0x9c00 # CJK UNIFIED IDEOGRAPH-9C00
|
||||
0xeee8 0x9d70 # CJK UNIFIED IDEOGRAPH-9D70
|
||||
0xeee9 0x9d6b # CJK UNIFIED IDEOGRAPH-9D6B
|
||||
0xeeea 0xfa2d # CJK COMPATIBILITY IDEOGRAPH-FA2D
|
||||
0xeeeb 0x9e19 # CJK UNIFIED IDEOGRAPH-9E19
|
||||
0xeeec 0x9ed1 # CJK UNIFIED IDEOGRAPH-9ED1
|
||||
0xeeef 0x2170 # SMALL ROMAN NUMERAL ONE
|
||||
0xeef0 0x2171 # SMALL ROMAN NUMERAL TWO
|
||||
0xeef1 0x2172 # SMALL ROMAN NUMERAL THREE
|
||||
0xeef2 0x2173 # SMALL ROMAN NUMERAL FOUR
|
||||
0xeef3 0x2174 # SMALL ROMAN NUMERAL FIVE
|
||||
0xeef4 0x2175 # SMALL ROMAN NUMERAL SIX
|
||||
0xeef5 0x2176 # SMALL ROMAN NUMERAL SEVEN
|
||||
0xeef6 0x2177 # SMALL ROMAN NUMERAL EIGHT
|
||||
0xeef7 0x2178 # SMALL ROMAN NUMERAL NINE
|
||||
0xeef8 0x2179 # SMALL ROMAN NUMERAL TEN
|
||||
0xeef9 0xffe2 # FULLWIDTH NOT SIGN
|
||||
0xeefa 0xffe4 # FULLWIDTH BROKEN BAR
|
||||
0xeefb 0xff07 # FULLWIDTH APOSTROPHE
|
||||
0xeefc 0xff02 # FULLWIDTH QUOTATION MARK
|
||||
0xfa4a 0x2160 # ROMAN NUMERAL ONE
|
||||
0xfa4b 0x2161 # ROMAN NUMERAL TWO
|
||||
0xfa4c 0x2162 # ROMAN NUMERAL THREE
|
||||
0xfa4d 0x2163 # ROMAN NUMERAL FOUR
|
||||
0xfa4e 0x2164 # ROMAN NUMERAL FIVE
|
||||
0xfa4f 0x2165 # ROMAN NUMERAL SIX
|
||||
0xfa50 0x2166 # ROMAN NUMERAL SEVEN
|
||||
0xfa51 0x2167 # ROMAN NUMERAL EIGHT
|
||||
0xfa52 0x2168 # ROMAN NUMERAL NINE
|
||||
0xfa53 0x2169 # ROMAN NUMERAL TEN
|
||||
0xfa54 0xffe2 # FULLWIDTH NOT SIGN
|
||||
0xfa58 0x3231 # PARENTHESIZED IDEOGRAPH STOCK
|
||||
0xfa59 0x2116 # NUMERO SIGN
|
||||
0xfa5a 0x2121 # TELEPHONE SIGN
|
||||
0xfa5b 0x2235 # BECAUSE
|
||||
24099
jdk/make/tools/CharsetMapping/MS936.map
Normal file
24099
jdk/make/tools/CharsetMapping/MS936.map
Normal file
File diff suppressed because it is too large
Load Diff
17384
jdk/make/tools/CharsetMapping/MS949.map
Normal file
17384
jdk/make/tools/CharsetMapping/MS949.map
Normal file
File diff suppressed because it is too large
Load Diff
19886
jdk/make/tools/CharsetMapping/MS950.map
Normal file
19886
jdk/make/tools/CharsetMapping/MS950.map
Normal file
File diff suppressed because it is too large
Load Diff
18
jdk/make/tools/CharsetMapping/MS950.nr
Normal file
18
jdk/make/tools/CharsetMapping/MS950.nr
Normal file
@ -0,0 +1,18 @@
|
||||
#
|
||||
# copy/paste of MS950.b2c-irreversible
|
||||
#
|
||||
# removed the entries of MS950.c2b-irreversible etries, this .nr
|
||||
# table only includes "b->c only" entries
|
||||
# (we don't need a MS950.c2b, the entries of MS950.c2b-irreversible
|
||||
# are added in MS950.b2c already)
|
||||
#
|
||||
0xF9FA 0x256D
|
||||
0xF9FB 0x256E
|
||||
0xF9FC 0x2570
|
||||
0xF9FD 0x256F
|
||||
0xA2CC 0x5341
|
||||
0xA2CE 0x5345
|
||||
0xF9F9 0x2550
|
||||
0xF9E9 0x255E
|
||||
0xF9EA 0x256A
|
||||
0xF9EB 0x2561
|
||||
@ -1,6 +1,14 @@
|
||||
#
|
||||
#clzName csName hisName dbtype pkg ascii b1min b1max b2min b2max
|
||||
#
|
||||
Johab x-Johab x-Johab basic sun.nio.cs.ext true 0x84 0xf9 0x31 0xfe
|
||||
EUC_CN GB2312 EUC_CN basic sun.nio.cs.ext true 0xa1 0xf7 0xa1 0xfe
|
||||
EUC_KR EUC-KR EUC_KR basic sun.nio.cs.ext true 0xa1 0xfd 0xa1 0xfe
|
||||
MS932 windows-31j MS932 basic sun.nio.cs.ext true 0x81 0xfc 0x40 0xfc
|
||||
MS936 x-mswin-936 MS936 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe
|
||||
MS949 x-windows-949 MS949 basic sun.nio.cs.ext true 0x81 0xfe 0x41 0xfe
|
||||
MS950 x-windows-950 MS950 basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe
|
||||
GBK GBK GBK basic sun.nio.cs.ext true 0x81 0xfe 0x40 0xfe
|
||||
IBM1381 x-IBM1381 Cp1381 basic sun.nio.cs.ext true 0x8c 0xf7 0xa1 0xfe
|
||||
IBM1383 x-IBM1383 Cp1383 euc_sim sun.nio.cs.ext true 0xa1 0xfe 0xa1 0xfe
|
||||
IBM930 x-IBM930 Cp930 ebcdic sun.nio.cs.ext false 0x40 0x7f 0x40 0xfe
|
||||
|
||||
@ -35,7 +35,7 @@ import static build.tools.charsetmapping.CharsetMapping.*;
|
||||
|
||||
public class GenerateDBCS {
|
||||
// pattern used by this class to read in mapping table
|
||||
static Pattern mPattern = Pattern.compile("(\\p{XDigit}++)\\s++(\\p{XDigit}++)(\\s++#.*)?");
|
||||
static Pattern mPattern = Pattern.compile("(?:0x)?(\\p{XDigit}++)\\s++(?:0x)?(\\p{XDigit}++)(?:\\s++#.*)?");
|
||||
public static void genDBCS(String args[]) throws Exception {
|
||||
|
||||
Scanner s = new Scanner(new File(args[0], args[2]));
|
||||
@ -260,10 +260,12 @@ public class GenerateDBCS {
|
||||
"StandardCharsets.aliases_" + clzName :
|
||||
"ExtendedCharsets.aliasesFor(\"" + csName + "\")")
|
||||
.replace("$NAME_CS$" , csName)
|
||||
.replace("$CONTAINS$", isASCII ?
|
||||
" return ((cs.name().equals(\"US-ASCII\")) || (cs instanceof "
|
||||
+ clzName + "));":
|
||||
" return (cs instanceof " + clzName + ");")
|
||||
.replace("$CONTAINS$",
|
||||
"MS932".equals(clzName)?
|
||||
"return ((cs.name().equals(\"US-ASCII\")) || (cs instanceof JIS_X_0201) || (cs instanceof " + clzName + "));":
|
||||
(isASCII ?
|
||||
"return ((cs.name().equals(\"US-ASCII\")) || (cs instanceof " + clzName + "));":
|
||||
"return (cs instanceof " + clzName + ");"))
|
||||
.replace("$HISTORICALNAME$",
|
||||
(hisName == null)? "" :
|
||||
" public String historicalName() { return \"" + hisName + "\"; }")
|
||||
|
||||
@ -683,10 +683,16 @@ static void
|
||||
SetClassPath(const char *s)
|
||||
{
|
||||
char *def;
|
||||
const char *orig = s;
|
||||
static const char format[] = "-Djava.class.path=%s";
|
||||
s = JLI_WildcardExpandClasspath(s);
|
||||
def = JLI_MemAlloc(JLI_StrLen(s) + 40);
|
||||
sprintf(def, "-Djava.class.path=%s", s);
|
||||
def = JLI_MemAlloc(sizeof(format)
|
||||
- 2 /* strlen("%s") */
|
||||
+ JLI_StrLen(s));
|
||||
sprintf(def, format, s);
|
||||
AddOption(def, NULL);
|
||||
if (s != orig)
|
||||
JLI_MemFree((char *) s);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -30,15 +30,15 @@ import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.SecureRandom;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
|
||||
/**
|
||||
* An abstract representation of file and directory pathnames.
|
||||
*
|
||||
@ -787,7 +787,7 @@ public class File
|
||||
* java.lang.SecurityManager#checkRead(java.lang.String)}</code>
|
||||
* method denies read access to the file
|
||||
*
|
||||
* @see Attributes#readBasicFileAttributes
|
||||
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
|
||||
*/
|
||||
public boolean isDirectory() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
@ -813,7 +813,7 @@ public class File
|
||||
* java.lang.SecurityManager#checkRead(java.lang.String)}</code>
|
||||
* method denies read access to the file
|
||||
*
|
||||
* @see Attributes#readBasicFileAttributes
|
||||
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
|
||||
*/
|
||||
public boolean isFile() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
@ -863,7 +863,7 @@ public class File
|
||||
* java.lang.SecurityManager#checkRead(java.lang.String)}</code>
|
||||
* method denies read access to the file
|
||||
*
|
||||
* @see Attributes#readBasicFileAttributes
|
||||
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
|
||||
*/
|
||||
public long lastModified() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
@ -887,7 +887,7 @@ public class File
|
||||
* java.lang.SecurityManager#checkRead(java.lang.String)}</code>
|
||||
* method denies read access to the file
|
||||
*
|
||||
* @see Attributes#readBasicFileAttributes
|
||||
* @see java.nio.file.attribute.Attributes#readBasicFileAttributes
|
||||
*/
|
||||
public long length() {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
@ -1369,9 +1369,10 @@ public class File
|
||||
* Sets the owner's or everybody's write permission for this abstract
|
||||
* pathname.
|
||||
*
|
||||
* <p> The {@link Attributes Attributes} class defines methods that operate
|
||||
* on file attributes including file permissions. This may be used when
|
||||
* finer manipulation of file permissions is required.
|
||||
* <p> The {@link java.nio.file.attribute.Attributes Attributes} class
|
||||
* defines methods that operate on file attributes including file
|
||||
* permissions. This may be used when finer manipulation of file permissions
|
||||
* is required.
|
||||
*
|
||||
* @param writable
|
||||
* If <code>true</code>, sets the access permission to allow write
|
||||
@ -1436,9 +1437,10 @@ public class File
|
||||
* Sets the owner's or everybody's read permission for this abstract
|
||||
* pathname.
|
||||
*
|
||||
* <p> The {@link Attributes Attributes} class defines methods that operate
|
||||
* on file attributes including file permissions. This may be used when
|
||||
* finer manipulation of file permissions is required.
|
||||
* <p> The {@link java.nio.file.attribute.Attributes Attributes} class
|
||||
* defines methods that operate on file attributes including file
|
||||
* permissions. This may be used when finer manipulation of file permissions
|
||||
* is required.
|
||||
*
|
||||
* @param readable
|
||||
* If <code>true</code>, sets the access permission to allow read
|
||||
@ -1509,9 +1511,10 @@ public class File
|
||||
* Sets the owner's or everybody's execute permission for this abstract
|
||||
* pathname.
|
||||
*
|
||||
* <p> The {@link Attributes Attributes} class defines methods that operate
|
||||
* on file attributes including file permissions. This may be used when
|
||||
* finer manipulation of file permissions is required.
|
||||
* <p> The {@link java.nio.file.attribute.Attributes Attributes} class
|
||||
* defines methods that operate on file attributes including file
|
||||
* permissions. This may be used when finer manipulation of file permissions
|
||||
* is required.
|
||||
*
|
||||
* @param executable
|
||||
* If <code>true</code>, sets the access permission to allow execute
|
||||
@ -1748,16 +1751,17 @@ public class File
|
||||
return fs.getSpace(this, FileSystem.SPACE_USABLE);
|
||||
}
|
||||
|
||||
|
||||
/* -- Temporary files -- */
|
||||
|
||||
private static class TemporaryDirectory {
|
||||
private TemporaryDirectory() { }
|
||||
static class TempDirectory {
|
||||
private TempDirectory() { }
|
||||
|
||||
static final String valueAsString = fs.normalize(
|
||||
AccessController.doPrivileged(new GetPropertyAction("java.io.tmpdir")));
|
||||
static final File valueAsFile =
|
||||
new File(valueAsString, fs.prefixLength(valueAsString));
|
||||
// temporary directory location
|
||||
private static final File tmpdir = new File(fs.normalize(AccessController
|
||||
.doPrivileged(new GetPropertyAction("java.io.tmpdir"))));
|
||||
static File location() {
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
// file name generation
|
||||
private static final SecureRandom random = new SecureRandom();
|
||||
@ -1770,25 +1774,6 @@ public class File
|
||||
}
|
||||
return new File(dir, prefix + Long.toString(n) + suffix);
|
||||
}
|
||||
|
||||
// default file permissions
|
||||
static final FileAttribute<Set<PosixFilePermission>> defaultPosixFilePermissions =
|
||||
PosixFilePermissions.asFileAttribute(EnumSet
|
||||
.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE));
|
||||
static final boolean isPosix = isPosix();
|
||||
static boolean isPosix() {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<Boolean>() {
|
||||
public Boolean run() {
|
||||
try {
|
||||
return FileSystems.getDefault().getPath(valueAsString)
|
||||
.getFileStore().supportsFileAttributeView("posix");
|
||||
} catch (IOException e) {
|
||||
throw new IOError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1869,12 +1854,11 @@ public class File
|
||||
if (suffix == null)
|
||||
suffix = ".tmp";
|
||||
|
||||
File tmpdir = (directory != null) ?
|
||||
directory : TemporaryDirectory.valueAsFile;
|
||||
File tmpdir = (directory != null) ? directory : TempDirectory.location();
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
File f;
|
||||
do {
|
||||
f = TemporaryDirectory.generateFile(prefix, suffix, tmpdir);
|
||||
f = TempDirectory.generateFile(prefix, suffix, tmpdir);
|
||||
if (sm != null) {
|
||||
try {
|
||||
sm.checkWrite(f.getPath());
|
||||
@ -1891,11 +1875,17 @@ public class File
|
||||
|
||||
/**
|
||||
* Creates an empty file in the default temporary-file directory, using
|
||||
* the given prefix and suffix to generate its name. Invoking this method
|
||||
* the given prefix and suffix to generate its name. Invoking this method
|
||||
* is equivalent to invoking <code>{@link #createTempFile(java.lang.String,
|
||||
* java.lang.String, java.io.File)
|
||||
* createTempFile(prefix, suffix, null)}</code>.
|
||||
*
|
||||
* <p> The {@link #createTemporaryFile(String,String,FileAttribute[])} method
|
||||
* provides an alternative method to create an empty file in the
|
||||
* temporary-file directory. Files created by that method may have more
|
||||
* restrictive access permissions to files created by this method and so
|
||||
* may be more suited to security-sensitive applications.
|
||||
*
|
||||
* @param prefix The prefix string to be used in generating the file's
|
||||
* name; must be at least three characters long
|
||||
*
|
||||
@ -1926,17 +1916,7 @@ public class File
|
||||
|
||||
/**
|
||||
* Creates an empty file in the default temporary-file directory, using
|
||||
* the given prefix and suffix to generate its name. This method is
|
||||
* equivalent to invoking the {@link #createTempFile(String,String)
|
||||
* createTempFile(prefix, suffix)} method with the addition that the
|
||||
* resulting pathname may be requested to be deleted when the Java virtual
|
||||
* machine terminates, and the initial file attributes to set atomically
|
||||
* when creating the file may be specified.
|
||||
*
|
||||
* <p> When the value of the {@code deleteOnExit} method is {@code true}
|
||||
* then the resulting file is requested to be deleted when the Java virtual
|
||||
* machine terminates as if by invoking the {@link #deleteOnExit deleteOnExit}
|
||||
* method.
|
||||
* the given prefix and suffix to generate its name.
|
||||
*
|
||||
* <p> The {@code attrs} parameter is an optional array of {@link FileAttribute
|
||||
* attributes} to set atomically when creating the file. Each attribute is
|
||||
@ -1944,6 +1924,12 @@ public class File
|
||||
* of the same name is included in the array then all but the last occurrence
|
||||
* is ignored.
|
||||
*
|
||||
* <p> Where the {@code attrs} parameter does not specify <i>access
|
||||
* permissions</i> to set atomically when creating the file, then the
|
||||
* resulting file may have more restrictive access permissions than files
|
||||
* created by the {@link #createTempFile(java.lang.String, java.lang.String)}
|
||||
* method.
|
||||
*
|
||||
* @param prefix
|
||||
* The prefix string to be used in generating the file's
|
||||
* name; must be at least three characters long
|
||||
@ -1951,9 +1937,6 @@ public class File
|
||||
* The suffix string to be used in generating the file's
|
||||
* name; may be {@code null}, in which case the suffix
|
||||
* {@code ".tmp"} will be used
|
||||
* @param deleteOnExit
|
||||
* {@code true} if the file denoted by resulting pathname be
|
||||
* deleted when the Java virtual machine terminates
|
||||
* @param attrs
|
||||
* An optional list of file attributes to set atomically when creating
|
||||
* the file
|
||||
@ -1961,7 +1944,7 @@ public class File
|
||||
* @return An abstract pathname denoting a newly-created empty file
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the <code>prefix</code> argument contains fewer than three
|
||||
* If the {@code prefix} argument contains fewer than three
|
||||
* characters
|
||||
* @throws UnsupportedOperationException
|
||||
* If the array contains an attribute that cannot be set atomically
|
||||
@ -1971,74 +1954,19 @@ public class File
|
||||
* @throws SecurityException
|
||||
* If a security manager exists and its <code>{@link
|
||||
* java.lang.SecurityManager#checkWrite(java.lang.String)}</code>
|
||||
* method does not allow a file to be created. When the {@code
|
||||
* deleteOnExit} parameter has the value {@code true} then the
|
||||
* security manager's {@link
|
||||
* java.lang.SecurityManager#checkDelete(java.lang.String)} is
|
||||
* invoked to check delete access to the file.
|
||||
* method does not allow a file to be created.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static File createTempFile(String prefix,
|
||||
String suffix,
|
||||
boolean deleteOnExit,
|
||||
FileAttribute<?>... attrs)
|
||||
public static File createTemporaryFile(String prefix,
|
||||
String suffix,
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
if (prefix.length() < 3)
|
||||
throw new IllegalArgumentException("Prefix string too short");
|
||||
suffix = (suffix == null) ? ".tmp" : suffix;
|
||||
|
||||
// special case POSIX environments so that 0600 is used as the file mode
|
||||
if (TemporaryDirectory.isPosix) {
|
||||
if (attrs.length == 0) {
|
||||
// no attributes so use default permissions
|
||||
attrs = new FileAttribute<?>[1];
|
||||
attrs[0] = TemporaryDirectory.defaultPosixFilePermissions;
|
||||
} else {
|
||||
// check if posix permissions given; if not use default
|
||||
boolean hasPermissions = false;
|
||||
for (int i=0; i<attrs.length; i++) {
|
||||
if (attrs[i].name().equals("posix:permissions")) {
|
||||
hasPermissions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasPermissions) {
|
||||
FileAttribute<?>[] copy = new FileAttribute<?>[attrs.length+1];
|
||||
System.arraycopy(attrs, 0, copy, 0, attrs.length);
|
||||
attrs = copy;
|
||||
attrs[attrs.length-1] =
|
||||
TemporaryDirectory.defaultPosixFilePermissions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// use Path#createFile to create file
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
for (;;) {
|
||||
File f = TemporaryDirectory
|
||||
.generateFile(prefix, suffix, TemporaryDirectory.valueAsFile);
|
||||
if (sm != null && deleteOnExit)
|
||||
sm.checkDelete(f.getPath());
|
||||
try {
|
||||
f.toPath().createFile(attrs);
|
||||
if (deleteOnExit)
|
||||
DeleteOnExitHook.add(f.getPath());
|
||||
return f;
|
||||
} catch (InvalidPathException e) {
|
||||
// don't reveal temporary directory location
|
||||
if (sm != null)
|
||||
throw new IllegalArgumentException("Invalid prefix or suffix");
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
// don't reveal temporary directory location
|
||||
if (sm != null)
|
||||
throw new SecurityException("Unable to create temporary file");
|
||||
throw e;
|
||||
} catch (FileAlreadyExistsException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return TempFileHelper.createFile(prefix, suffix, attrs);
|
||||
}
|
||||
|
||||
/* -- Basic infrastructure -- */
|
||||
@ -2153,40 +2081,45 @@ public class File
|
||||
|
||||
/**
|
||||
* Returns a {@link Path java.nio.file.Path} object constructed from the
|
||||
* this abstract path. The first invocation of this method works as if
|
||||
* invoking it were equivalent to evaluating the expression:
|
||||
* this abstract path. The resulting {@code Path} is associated with the
|
||||
* {@link java.nio.file.FileSystems#getDefault default-filesystem}.
|
||||
*
|
||||
* <p> The first invocation of this method works as if invoking it were
|
||||
* equivalent to evaluating the expression:
|
||||
* <blockquote><pre>
|
||||
* {@link FileSystems#getDefault FileSystems.getDefault}().{@link FileSystem#getPath getPath}(this.{@link #getPath getPath}());
|
||||
* {@link java.nio.file.FileSystems#getDefault FileSystems.getDefault}().{@link
|
||||
* java.nio.file.FileSystem#getPath getPath}(this.{@link #getPath getPath}());
|
||||
* </pre></blockquote>
|
||||
* Subsequent invocations of this method return the same {@code Path}.
|
||||
*
|
||||
* <p> If this abstract pathname is the empty abstract pathname then this
|
||||
* method returns a {@code Path} that may be used to access to the current
|
||||
* method returns a {@code Path} that may be used to access the current
|
||||
* user directory.
|
||||
*
|
||||
* @return A {@code Path} constructed from this abstract path. The resulting
|
||||
* {@code Path} is associated with the {@link FileSystems#getDefault
|
||||
* default-filesystem}.
|
||||
* @return a {@code Path} constructed from this abstract path
|
||||
*
|
||||
* @throws InvalidPathException
|
||||
* If a {@code Path} object cannot be constructed from the abstract
|
||||
* if a {@code Path} object cannot be constructed from the abstract
|
||||
* path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath})
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public Path toPath() {
|
||||
if (filePath == null) {
|
||||
Path result = filePath;
|
||||
if (result == null) {
|
||||
synchronized (this) {
|
||||
if (filePath == null) {
|
||||
result = filePath;
|
||||
if (result == null) {
|
||||
if (path.length() == 0) {
|
||||
// assume default file system treats "." as current directory
|
||||
filePath = Paths.get(".");
|
||||
result = Paths.get(".");
|
||||
} else {
|
||||
filePath = Paths.get(path);
|
||||
result = Paths.get(path);
|
||||
}
|
||||
filePath = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
139
jdk/src/share/classes/java/io/TempFileHelper.java
Normal file
139
jdk/src/share/classes/java/io/TempFileHelper.java
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package java.io;
|
||||
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
import static java.nio.file.attribute.PosixFilePermission.*;
|
||||
import java.util.Set;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* Helper class to support creation of temporary files and directory with
|
||||
* initial attributes.
|
||||
*/
|
||||
|
||||
class TempFileHelper {
|
||||
private TempFileHelper() { }
|
||||
|
||||
// default file and directory permissions (lazily initialized)
|
||||
private static class PermissionsHolder {
|
||||
static final boolean hasPosixPermissions = FileSystems.getDefault()
|
||||
.supportedFileAttributeViews().contains("posix");
|
||||
static final FileAttribute<Set<PosixFilePermission>> filePermissions =
|
||||
PosixFilePermissions.asFileAttribute(EnumSet.of(OWNER_READ, OWNER_WRITE));
|
||||
static final FileAttribute<Set<PosixFilePermission>> directoryPermissions =
|
||||
PosixFilePermissions.asFileAttribute(EnumSet
|
||||
.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file or directory in the temporary directory.
|
||||
*/
|
||||
private static File create(String prefix,
|
||||
String suffix,
|
||||
FileAttribute[] attrs,
|
||||
boolean isDirectory)
|
||||
throws IOException
|
||||
{
|
||||
// in POSIX environments use default file and directory permissions
|
||||
// if initial permissions not given by caller.
|
||||
if (PermissionsHolder.hasPosixPermissions) {
|
||||
if (attrs.length == 0) {
|
||||
// no attributes so use default permissions
|
||||
attrs = new FileAttribute<?>[1];
|
||||
attrs[0] = (isDirectory) ? PermissionsHolder.directoryPermissions :
|
||||
PermissionsHolder.filePermissions;
|
||||
} else {
|
||||
// check if posix permissions given; if not use default
|
||||
boolean hasPermissions = false;
|
||||
for (int i=0; i<attrs.length; i++) {
|
||||
if (attrs[i].name().equals("posix:permissions")) {
|
||||
hasPermissions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasPermissions) {
|
||||
FileAttribute<?>[] copy = new FileAttribute<?>[attrs.length+1];
|
||||
System.arraycopy(attrs, 0, copy, 0, attrs.length);
|
||||
attrs = copy;
|
||||
attrs[attrs.length-1] = (isDirectory) ?
|
||||
PermissionsHolder.directoryPermissions :
|
||||
PermissionsHolder.filePermissions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// loop generating random names until file or directory can be created
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
for (;;) {
|
||||
File tmpdir = File.TempDirectory.location();
|
||||
File f = File.TempDirectory.generateFile(prefix, suffix, tmpdir);
|
||||
try {
|
||||
if (isDirectory) {
|
||||
f.toPath().createDirectory(attrs);
|
||||
} else {
|
||||
f.toPath().createFile(attrs);
|
||||
}
|
||||
return f;
|
||||
} catch (InvalidPathException e) {
|
||||
// don't reveal temporary directory location
|
||||
if (sm != null)
|
||||
throw new IllegalArgumentException("Invalid prefix or suffix");
|
||||
throw e;
|
||||
} catch (SecurityException e) {
|
||||
// don't reveal temporary directory location
|
||||
if (sm != null)
|
||||
throw new SecurityException("Unable to create temporary file");
|
||||
throw e;
|
||||
} catch (FileAlreadyExistsException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file in the temporary directory.
|
||||
*/
|
||||
static File createFile(String prefix, String suffix, FileAttribute[] attrs)
|
||||
throws IOException
|
||||
{
|
||||
return create(prefix, suffix, attrs, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a directory in the temporary directory.
|
||||
*/
|
||||
static File createDirectory(String prefix, FileAttribute[] attrs)
|
||||
throws IOException
|
||||
{
|
||||
return create(prefix, "", attrs, true);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -40,6 +40,12 @@ public enum ElementType {
|
||||
/** Class, interface (including annotation type), or enum declaration */
|
||||
TYPE,
|
||||
|
||||
/** Uses of a type */
|
||||
TYPE_USE,
|
||||
|
||||
/** type parameters */
|
||||
TYPE_PARAMETER,
|
||||
|
||||
/** Field declaration (includes enum constants) */
|
||||
FIELD,
|
||||
|
||||
|
||||
@ -34,7 +34,6 @@ import java.util.logging.LoggingMXBean;
|
||||
import java.util.logging.LogManager;
|
||||
import java.nio.BufferPoolMXBean;
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
@ -198,10 +197,7 @@ enum PlatformComponent {
|
||||
"java.nio", "BufferPool", keyProperties("name"),
|
||||
new MXBeanFetcher<BufferPoolMXBean>() {
|
||||
public List<BufferPoolMXBean> getMXBeans() {
|
||||
List<BufferPoolMXBean> pools = new ArrayList<BufferPoolMXBean>(2);
|
||||
pools.add( sun.misc.SharedSecrets.getJavaNioAccess().getDirectBufferPoolMXBean() );
|
||||
pools.add( sun.nio.ch.FileChannelImpl.getMappedBufferPoolMXBean() );
|
||||
return pools;
|
||||
return ManagementFactoryHelper.getBufferPoolMXBeans();
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
@ -1101,7 +1101,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||
// See "Hacker's Delight" section 2-12 for explanation of
|
||||
// the overflow test.
|
||||
if ( (((sum ^ xs) & (sum ^ ys))) >= 0L) // not overflowed
|
||||
return new BigDecimal(null, sum, rscale, 0);
|
||||
return BigDecimal.valueOf(sum, rscale);
|
||||
}
|
||||
if (fst == null)
|
||||
fst = BigInteger.valueOf(xs);
|
||||
@ -1311,9 +1311,9 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||
* would occur since division is expensive on most CPUs.
|
||||
*/
|
||||
long product = x * y;
|
||||
int prec = this.precision() + multiplicand.precision();
|
||||
long prec = this.precision() + multiplicand.precision();
|
||||
if (prec < 19 || (prec < 21 && (y == 0 || product / y == x)))
|
||||
return new BigDecimal(null, product, productScale, 0);
|
||||
return BigDecimal.valueOf(product, productScale);
|
||||
return new BigDecimal(BigInteger.valueOf(x).multiply(y), INFLATED,
|
||||
productScale, 0);
|
||||
}
|
||||
@ -1584,7 +1584,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||
return (preferredScale >= 0 &&
|
||||
preferredScale < ZERO_SCALED_BY.length) ?
|
||||
ZERO_SCALED_BY[preferredScale] :
|
||||
new BigDecimal(null, 0, preferredScale, 1);
|
||||
BigDecimal.valueOf(0, preferredScale);
|
||||
else {
|
||||
this.inflate();
|
||||
divisor.inflate();
|
||||
|
||||
@ -29,7 +29,6 @@ import java.io.OutputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.prefs.Preferences;
|
||||
import sun.net.www.ParseUtil;
|
||||
/* import org.ietf.jgss.*; */
|
||||
|
||||
@ -41,7 +40,7 @@ import sun.net.www.ParseUtil;
|
||||
|
||||
class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
private String server = null;
|
||||
private int port = DEFAULT_PORT;
|
||||
private int serverPort = DEFAULT_PORT;
|
||||
private InetSocketAddress external_address;
|
||||
private boolean useV4 = false;
|
||||
private Socket cmdsock = null;
|
||||
@ -54,7 +53,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
|
||||
SocksSocketImpl(String server, int port) {
|
||||
this.server = server;
|
||||
this.port = (port == -1 ? DEFAULT_PORT : port);
|
||||
this.serverPort = (port == -1 ? DEFAULT_PORT : port);
|
||||
}
|
||||
|
||||
SocksSocketImpl(Proxy proxy) {
|
||||
@ -63,7 +62,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
InetSocketAddress ad = (InetSocketAddress) a;
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
server = ad.getHostString();
|
||||
port = ad.getPort();
|
||||
serverPort = ad.getPort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,16 +112,12 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
*/
|
||||
private boolean authenticate(byte method, InputStream in,
|
||||
BufferedOutputStream out) throws IOException {
|
||||
byte[] data = null;
|
||||
int i;
|
||||
// No Authentication required. We're done then!
|
||||
if (method == NO_AUTH)
|
||||
return true;
|
||||
/**
|
||||
* User/Password authentication. Try, in that order :
|
||||
* - The application provided Authenticator, if any
|
||||
* - The user preferences java.net.socks.username &
|
||||
* java.net.socks.password
|
||||
* - the user.name & no password (backward compatibility behavior).
|
||||
*/
|
||||
if (method == USER_PASSW) {
|
||||
@ -134,40 +129,15 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
new java.security.PrivilegedAction<PasswordAuthentication>() {
|
||||
public PasswordAuthentication run() {
|
||||
return Authenticator.requestPasswordAuthentication(
|
||||
server, addr, port, "SOCKS5", "SOCKS authentication", null);
|
||||
server, addr, serverPort, "SOCKS5", "SOCKS authentication", null);
|
||||
}
|
||||
});
|
||||
if (pw != null) {
|
||||
userName = pw.getUserName();
|
||||
password = new String(pw.getPassword());
|
||||
} else {
|
||||
final Preferences prefs = Preferences.userRoot().node("/java/net/socks");
|
||||
try {
|
||||
userName = AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<String>() {
|
||||
public String run() throws IOException {
|
||||
return prefs.get("username", null);
|
||||
}
|
||||
});
|
||||
} catch (java.security.PrivilegedActionException pae) {
|
||||
throw (IOException) pae.getException();
|
||||
}
|
||||
|
||||
if (userName != null) {
|
||||
try {
|
||||
password = AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<String>() {
|
||||
public String run() throws IOException {
|
||||
return prefs.get("password", null);
|
||||
}
|
||||
});
|
||||
} catch (java.security.PrivilegedActionException pae) {
|
||||
throw (IOException) pae.getException();
|
||||
}
|
||||
} else {
|
||||
userName = java.security.AccessController.doPrivileged(
|
||||
userName = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("user.name"));
|
||||
}
|
||||
}
|
||||
if (userName == null)
|
||||
return false;
|
||||
@ -188,8 +158,8 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
} else
|
||||
out.write(0);
|
||||
out.flush();
|
||||
data = new byte[2];
|
||||
i = readSocksReply(in, data);
|
||||
byte[] data = new byte[2];
|
||||
int i = readSocksReply(in, data);
|
||||
if (i != 2 || data[1] != 0) {
|
||||
/* RFC 1929 specifies that the connection MUST be closed if
|
||||
authentication fails */
|
||||
@ -322,6 +292,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
* @throws IllegalArgumentException if endpoint is null or a
|
||||
* SocketAddress subclass not supported by this socket
|
||||
*/
|
||||
@Override
|
||||
protected void connect(SocketAddress endpoint, int timeout) throws IOException {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (endpoint == null || !(endpoint instanceof InetSocketAddress))
|
||||
@ -352,7 +323,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
super.connect(epoint, timeout);
|
||||
return;
|
||||
}
|
||||
URI uri = null;
|
||||
URI uri;
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
String host = epoint.getHostString();
|
||||
// IPv6 litteral?
|
||||
@ -365,6 +336,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
} catch (URISyntaxException e) {
|
||||
// This shouldn't happen
|
||||
assert false : e;
|
||||
uri = null;
|
||||
}
|
||||
Proxy p = null;
|
||||
IOException savedExc = null;
|
||||
@ -386,18 +358,18 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
throw new SocketException("Unknow address type for proxy: " + p);
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
server = ((InetSocketAddress) p.address()).getHostString();
|
||||
port = ((InetSocketAddress) p.address()).getPort();
|
||||
serverPort = ((InetSocketAddress) p.address()).getPort();
|
||||
|
||||
// Connects to the SOCKS server
|
||||
try {
|
||||
privilegedConnect(server, port, timeout);
|
||||
privilegedConnect(server, serverPort, timeout);
|
||||
// Worked, let's get outta here
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
// Ooops, let's notify the ProxySelector
|
||||
sel.connectFailed(uri,p.address(),e);
|
||||
server = null;
|
||||
port = -1;
|
||||
serverPort = -1;
|
||||
savedExc = e;
|
||||
// Will continue the while loop and try the next proxy
|
||||
}
|
||||
@ -414,7 +386,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
} else {
|
||||
// Connects to the SOCKS server
|
||||
try {
|
||||
privilegedConnect(server, port, timeout);
|
||||
privilegedConnect(server, serverPort, timeout);
|
||||
} catch (IOException e) {
|
||||
throw new SocketException(e.getMessage());
|
||||
}
|
||||
@ -487,7 +459,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
if (i != 4)
|
||||
throw new SocketException("Reply from SOCKS server has bad length");
|
||||
SocketException ex = null;
|
||||
int nport, len;
|
||||
int len;
|
||||
byte[] addr;
|
||||
switch (data[1]) {
|
||||
case REQUEST_OK:
|
||||
@ -502,8 +474,6 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
i = readSocksReply(in, data);
|
||||
if (i != 2)
|
||||
throw new SocketException("Reply from SOCKS server badly formatted");
|
||||
nport = ((int)data[0] & 0xff) << 8;
|
||||
nport += ((int)data[1] & 0xff);
|
||||
break;
|
||||
case DOMAIN_NAME:
|
||||
len = data[1];
|
||||
@ -515,8 +485,6 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
i = readSocksReply(in, data);
|
||||
if (i != 2)
|
||||
throw new SocketException("Reply from SOCKS server badly formatted");
|
||||
nport = ((int)data[0] & 0xff) << 8;
|
||||
nport += ((int)data[1] & 0xff);
|
||||
break;
|
||||
case IPV6:
|
||||
len = data[1];
|
||||
@ -528,8 +496,6 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
i = readSocksReply(in, data);
|
||||
if (i != 2)
|
||||
throw new SocketException("Reply from SOCKS server badly formatted");
|
||||
nport = ((int)data[0] & 0xff) << 8;
|
||||
nport += ((int)data[1] & 0xff);
|
||||
break;
|
||||
default:
|
||||
ex = new SocketException("Reply from SOCKS server contains wrong code");
|
||||
@ -663,7 +629,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
*/
|
||||
return;
|
||||
}
|
||||
URI uri = null;
|
||||
URI uri;
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
String host = saddr.getHostString();
|
||||
// IPv6 litteral?
|
||||
@ -676,6 +642,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
} catch (URISyntaxException e) {
|
||||
// This shouldn't happen
|
||||
assert false : e;
|
||||
uri = null;
|
||||
}
|
||||
Proxy p = null;
|
||||
Exception savedExc = null;
|
||||
@ -695,7 +662,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
throw new SocketException("Unknow address type for proxy: " + p);
|
||||
// Use getHostString() to avoid reverse lookups
|
||||
server = ((InetSocketAddress) p.address()).getHostString();
|
||||
port = ((InetSocketAddress) p.address()).getPort();
|
||||
serverPort = ((InetSocketAddress) p.address()).getPort();
|
||||
|
||||
// Connects to the SOCKS server
|
||||
try {
|
||||
@ -703,7 +670,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
new PrivilegedExceptionAction<Void>() {
|
||||
public Void run() throws Exception {
|
||||
cmdsock = new Socket(new PlainSocketImpl());
|
||||
cmdsock.connect(new InetSocketAddress(server, port));
|
||||
cmdsock.connect(new InetSocketAddress(server, serverPort));
|
||||
cmdIn = cmdsock.getInputStream();
|
||||
cmdOut = cmdsock.getOutputStream();
|
||||
return null;
|
||||
@ -713,7 +680,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
// Ooops, let's notify the ProxySelector
|
||||
sel.connectFailed(uri,p.address(),new SocketException(e.getMessage()));
|
||||
server = null;
|
||||
port = -1;
|
||||
serverPort = -1;
|
||||
cmdsock = null;
|
||||
savedExc = e;
|
||||
// Will continue the while loop and try the next proxy
|
||||
@ -734,7 +701,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
new PrivilegedExceptionAction<Void>() {
|
||||
public Void run() throws Exception {
|
||||
cmdsock = new Socket(new PlainSocketImpl());
|
||||
cmdsock.connect(new InetSocketAddress(server, port));
|
||||
cmdsock.connect(new InetSocketAddress(server, serverPort));
|
||||
cmdIn = cmdsock.getInputStream();
|
||||
cmdOut = cmdsock.getOutputStream();
|
||||
return null;
|
||||
@ -809,7 +776,6 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
switch (data[1]) {
|
||||
case REQUEST_OK:
|
||||
// success!
|
||||
InetSocketAddress real_end = null;
|
||||
switch(data[3]) {
|
||||
case IPV4:
|
||||
addr = new byte[4];
|
||||
@ -1016,6 +982,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
* @return the value of this socket's <code>address</code> field.
|
||||
* @see java.net.SocketImpl#address
|
||||
*/
|
||||
@Override
|
||||
protected InetAddress getInetAddress() {
|
||||
if (external_address != null)
|
||||
return external_address.getAddress();
|
||||
@ -1029,6 +996,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
* @return the value of this socket's <code>port</code> field.
|
||||
* @see java.net.SocketImpl#port
|
||||
*/
|
||||
@Override
|
||||
protected int getPort() {
|
||||
if (external_address != null)
|
||||
return external_address.getPort();
|
||||
@ -1036,6 +1004,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
return super.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLocalPort() {
|
||||
if (socket != null)
|
||||
return super.getLocalPort();
|
||||
@ -1045,6 +1014,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
return super.getLocalPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void close() throws IOException {
|
||||
if (cmdsock != null)
|
||||
cmdsock.close();
|
||||
|
||||
@ -26,11 +26,8 @@
|
||||
package java.nio;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
|
||||
/**
|
||||
* Access to bits, native and otherwise.
|
||||
@ -676,55 +673,34 @@ class Bits { // package-private
|
||||
}
|
||||
}
|
||||
|
||||
// -- Management interface for monitoring of direct buffer usage --
|
||||
// -- Monitoring of direct buffer usage --
|
||||
|
||||
static {
|
||||
// setup access to this package in SharedSecrets
|
||||
sun.misc.SharedSecrets.setJavaNioAccess(
|
||||
new sun.misc.JavaNioAccess() {
|
||||
@Override
|
||||
public BufferPoolMXBean getDirectBufferPoolMXBean() {
|
||||
return LazyInitialization.directBufferPoolMXBean;
|
||||
public sun.misc.JavaNioAccess.BufferPool getDirectBufferPool() {
|
||||
return new sun.misc.JavaNioAccess.BufferPool() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "direct";
|
||||
}
|
||||
@Override
|
||||
public long getCount() {
|
||||
return Bits.count;
|
||||
}
|
||||
@Override
|
||||
public long getTotalCapacity() {
|
||||
return Bits.usedMemory;
|
||||
}
|
||||
@Override
|
||||
public long getMemoryUsed() {
|
||||
return Bits.reservedMemory;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Lazy initialization of management interface
|
||||
private static class LazyInitialization {
|
||||
static final BufferPoolMXBean directBufferPoolMXBean = directBufferPoolMXBean();
|
||||
|
||||
private static BufferPoolMXBean directBufferPoolMXBean() {
|
||||
final String pool = "direct";
|
||||
final ObjectName obj;
|
||||
try {
|
||||
obj = new ObjectName("java.nio:type=BufferPool,name=" + pool);
|
||||
} catch (MalformedObjectNameException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
return new BufferPoolMXBean() {
|
||||
@Override
|
||||
public ObjectName getObjectName() {
|
||||
return obj;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return pool;
|
||||
}
|
||||
@Override
|
||||
public long getCount() {
|
||||
return Bits.count;
|
||||
}
|
||||
@Override
|
||||
public long getTotalCapacity() {
|
||||
return Bits.usedMemory;
|
||||
}
|
||||
@Override
|
||||
public long getMemoryUsed() {
|
||||
return Bits.reservedMemory;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// -- Bulk get/put acceleration --
|
||||
|
||||
@ -30,7 +30,6 @@ package java.nio;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
import sun.nio.ch.FileChannelImpl;
|
||||
|
||||
|
||||
class Direct$Type$Buffer$RW$$BO$
|
||||
|
||||
@ -47,7 +47,7 @@ import java.io.IOException;
|
||||
* so that method invocations on the implementation class can be chained.
|
||||
*
|
||||
* @since 1.7
|
||||
* @see java.nio.file.FileRef#newByteChannel
|
||||
* @see java.nio.file.Path#newByteChannel
|
||||
*/
|
||||
|
||||
public interface SeekableByteChannel
|
||||
|
||||
@ -30,7 +30,7 @@ package java.nio.file;
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @see FileRef#checkAccess
|
||||
* @see Path#checkAccess
|
||||
*/
|
||||
|
||||
public enum AccessMode {
|
||||
|
||||
@ -27,6 +27,7 @@ package java.nio.file;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* An object to iterate over the entries in a directory. A directory stream
|
||||
@ -50,13 +51,10 @@ import java.io.Closeable;
|
||||
*
|
||||
* <p> A {@code DirectoryStream} is opened upon creation and is closed by
|
||||
* invoking the {@link #close close} method. Closing the directory stream
|
||||
* releases any resources associated with the stream. The {@link
|
||||
* Files#withDirectory Files.withDirectory} utility method is useful for cases
|
||||
* where a task is performed on entries in a directory. This method automatically
|
||||
* closes the directory stream when iteration is complete (or an error occurs).
|
||||
* Once a directory stream is closed, all further method invocations on the
|
||||
* iterator throw {@link java.util.concurrent.ConcurrentModificationException}
|
||||
* with cause {@link ClosedDirectoryStreamException}.
|
||||
* releases any resources associated with the stream. Once a directory stream
|
||||
* is closed, all further method invocations on the iterator throw {@link
|
||||
* java.util.concurrent.ConcurrentModificationException} with cause {@link
|
||||
* ClosedDirectoryStreamException}.
|
||||
*
|
||||
* <p> A directory stream is not required to be <i>asynchronously closeable</i>.
|
||||
* If a thread is blocked on the directory stream's iterator reading from the
|
||||
@ -79,7 +77,7 @@ import java.io.Closeable;
|
||||
*
|
||||
* <p> The iterator's {@link Iterator#remove() remove} method removes the
|
||||
* directory entry for the last element returned by the iterator, as if by
|
||||
* invoking the {@link FileRef#delete delete} method. If an I/O error or
|
||||
* invoking the {@link Path#delete delete} method. If an I/O error or
|
||||
* security exception occurs then {@code ConcurrentModificationException} is
|
||||
* thrown with the cause.
|
||||
*
|
||||
@ -104,10 +102,6 @@ public interface DirectoryStream<T>
|
||||
* newDirectoryStream} method when opening a directory to iterate over the
|
||||
* entries in the directory.
|
||||
*
|
||||
* <p> The {@link DirectoryStreamFilters} class defines factory methods to
|
||||
* create filters for a number of common usages and also methods to combine
|
||||
* filters.
|
||||
*
|
||||
* @param <T> the type of the directory entry
|
||||
*
|
||||
* @since 1.7
|
||||
@ -120,8 +114,11 @@ public interface DirectoryStream<T>
|
||||
* the directory entry to be tested
|
||||
*
|
||||
* @return {@code true} if the directory entry should be accepted
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
boolean accept(T entry);
|
||||
boolean accept(T entry) throws IOException;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,210 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package java.nio.file;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.IOError;
|
||||
import sun.nio.fs.MimeType;
|
||||
|
||||
/**
|
||||
* This class consists exclusively of static methods that construct or combine
|
||||
* filters.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public final class DirectoryStreamFilters {
|
||||
private DirectoryStreamFilters() { }
|
||||
|
||||
/**
|
||||
* Constructs a directory stream filter that filters directory entries by
|
||||
* their <a href="http://www.ietf.org/rfc/rfc2045.txt">MIME</a> content
|
||||
* type. The directory stream filter's {@link
|
||||
* java.nio.file.DirectoryStream.Filter#accept accept} method returns {@code
|
||||
* true} if the content type of the directory entry can be determined by
|
||||
* invoking the {@link Files#probeContentType probeContentType} method, and
|
||||
* the content type matches the given content type.
|
||||
*
|
||||
* <p> The {@code type} parameter is the value of a Multipurpose Internet
|
||||
* Mail Extension (MIME) content type as defined by <a
|
||||
* href="http://www.ietf.org/rfc/rfc2045.txt"><i>RFC 2045: Multipurpose
|
||||
* Internet Mail Extensions (MIME) Part One: Format of Internet Message
|
||||
* Bodies</i></a>. It is parsable according to the grammar in the RFC. Any
|
||||
* space characters (<code>'\u0020'</code>) surrounding its components are
|
||||
* ignored. The {@code type} parameter is parsed into its primary and subtype
|
||||
* components which are used to match the primary and subtype components of
|
||||
* each directory entry's content type. Parameters are not allowed. The
|
||||
* primary type matches if it has value {@code '*'} or is equal to the
|
||||
* primary type of the directory entry's content type without regard to
|
||||
* case. The subtype matches if has the value {@code '*'} or is equal to the
|
||||
* subtype of the directory entry's content type without regard to case. If
|
||||
* both the primary and subtype match then the filter's {@code accept} method
|
||||
* returns {@code true}. If the content type of a directory entry cannot be
|
||||
* determined then the entry is filtered.
|
||||
*
|
||||
* <p> The {@code accept} method of the resulting directory stream filter
|
||||
* throws {@link IOError} if the probing of the content type fails by
|
||||
* throwing an {@link IOException}. Security exceptions are also propogated
|
||||
* to the caller of the {@code accept} method.
|
||||
*
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we require to list only the HTML files in a directory.
|
||||
* <pre>
|
||||
* DirectoryStream.Filter<FileRef> filter =
|
||||
* DirectoryStreamFilters.newContentTypeFilter("text/html");
|
||||
* </pre>
|
||||
*
|
||||
* @param type
|
||||
* the content type
|
||||
*
|
||||
* @return a new directory stream filter
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the {@code type} parameter cannot be parsed as a MIME type
|
||||
* or it has parameters
|
||||
*/
|
||||
public static <T extends FileRef> DirectoryStream.Filter<T>
|
||||
newContentTypeFilter(String type)
|
||||
{
|
||||
final MimeType matchType = MimeType.parse(type);
|
||||
if (matchType.hasParameters())
|
||||
throw new IllegalArgumentException("Parameters not allowed");
|
||||
return new DirectoryStream.Filter<T>() {
|
||||
@Override
|
||||
public boolean accept(T entry) {
|
||||
String fileType;
|
||||
try {
|
||||
fileType = Files.probeContentType(entry);
|
||||
} catch (IOException x) {
|
||||
throw new IOError(x);
|
||||
}
|
||||
if (fileType != null) {
|
||||
return matchType.match(fileType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a directory stream filter that {@link DirectoryStream.Filter#accept
|
||||
* accepts} a directory entry if the entry is accepted by all of the given
|
||||
* filters.
|
||||
*
|
||||
* <p> This method returns a filter that invokes, in iterator order, the
|
||||
* {@code accept} method of each of the filters. If {@code false} is returned
|
||||
* by any of the filters then the directory entry is filtered. If the
|
||||
* directory entry is not filtered then the resulting filter accepts the
|
||||
* entry. If the iterator returns zero elements then the resulting filter
|
||||
* accepts all directory entries.
|
||||
*
|
||||
* <p> <b>Usage Example:</b>
|
||||
* <pre>
|
||||
* List<DirectoryStream.Filter<? super Path>> filters = ...
|
||||
* DirectoryStream.Filter<Path> filter = DirectoryStreamFilters.allOf(filters);
|
||||
* </pre>
|
||||
*
|
||||
* @param filters
|
||||
* the sequence of filters
|
||||
*
|
||||
* @return the resulting filter
|
||||
*/
|
||||
public static <T> DirectoryStream.Filter<T>
|
||||
allOf(final Iterable<? extends DirectoryStream.Filter<? super T>> filters)
|
||||
{
|
||||
if (filters == null)
|
||||
throw new NullPointerException("'filters' is null");
|
||||
return new DirectoryStream.Filter<T>() {
|
||||
@Override
|
||||
public boolean accept(T entry) {
|
||||
for (DirectoryStream.Filter<? super T> filter: filters) {
|
||||
if (!filter.accept(entry))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a directory stream filter that {@link DirectoryStream.Filter#accept
|
||||
* accepts} a directory entry if the entry is accepted by one or more of
|
||||
* the given filters.
|
||||
*
|
||||
* <p> This method returns a filter that invokes, in iteration order, the
|
||||
* {@code accept} method of each of filter. If {@code true} is returned by
|
||||
* any of the filters then the directory entry is accepted. If none of the
|
||||
* filters accepts the directory entry then it is filtered. If the iterator
|
||||
* returns zero elements then the resulting filter filters all directory
|
||||
* entries.
|
||||
*
|
||||
* @param filters
|
||||
* the sequence of filters
|
||||
*
|
||||
* @return the resulting filter
|
||||
*/
|
||||
public static <T> DirectoryStream.Filter<T>
|
||||
anyOf(final Iterable<? extends DirectoryStream.Filter<? super T>> filters)
|
||||
{
|
||||
if (filters == null)
|
||||
throw new NullPointerException("'filters' is null");
|
||||
return new DirectoryStream.Filter<T>() {
|
||||
@Override
|
||||
public boolean accept(T entry) {
|
||||
for (DirectoryStream.Filter<? super T> filter: filters) {
|
||||
if (filter.accept(entry))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a directory stream filter that is the <em>complement</em> of the
|
||||
* given filter. The resulting filter {@link
|
||||
* java.nio.file.DirectoryStream.Filter#accept accepts} a directory entry
|
||||
* if filtered by the given filter, and filters any entries that are accepted
|
||||
* by the given filter.
|
||||
*
|
||||
* @param filter
|
||||
* the given filter
|
||||
*
|
||||
* @return the resulting filter that is the complement of the given filter
|
||||
*/
|
||||
public static <T> DirectoryStream.Filter<T>
|
||||
complementOf(final DirectoryStream.Filter<T> filter)
|
||||
{
|
||||
if (filter == null)
|
||||
throw new NullPointerException("'filter' is null");
|
||||
return new DirectoryStream.Filter<T>() {
|
||||
@Override
|
||||
public boolean accept(T entry) {
|
||||
return !filter.accept(entry);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -26,225 +26,85 @@
|
||||
package java.nio.file;
|
||||
|
||||
import java.nio.file.attribute.*;
|
||||
import java.nio.channels.SeekableByteChannel;
|
||||
import java.util.Map;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A reference to a file.
|
||||
*
|
||||
* <p> A {@code FileRef} is an object that locates a file and defines methods to
|
||||
* access the file. The means by which the file is located depends on the
|
||||
* implementation. In many cases, a file is located by a {@link Path} but it may
|
||||
* be located by other means such as a file-system identifier.
|
||||
*
|
||||
* <p> This interface defines the following operations:
|
||||
* <ul>
|
||||
* <li><p> The {@link #newByteChannel newByteChannel} method
|
||||
* may be used to open a file and obtain a byte channel for reading or
|
||||
* writing. </p></li>
|
||||
* <li><p> The {@link #delete delete} method may be used to delete a file.
|
||||
* </p></li>
|
||||
* <li><p> The {@link #checkAccess checkAccess} method may be used to check
|
||||
* the existence or accessibility of a file. </p></li>
|
||||
* <li><p> The {@link #isSameFile isSameFile} method may be used to test if
|
||||
* two file references locate the same file. </p></li>
|
||||
* <li><p> The {@link #getFileStore getFileStore} method may be used to
|
||||
* obtain the {@link FileStore} representing the storage where a file is
|
||||
* located. </p></li>
|
||||
* </ul>
|
||||
*
|
||||
* <p> Access to associated metadata or file attributes requires an appropriate
|
||||
* {@link FileAttributeView FileAttributeView}. The {@link
|
||||
* #getFileAttributeView(Class,LinkOption[]) getFileAttributeView(Class,LinkOption[])}
|
||||
* method may be used to obtain a file attribute view that defines type-safe
|
||||
* methods to read or update file attributes. The {@link
|
||||
* #getFileAttributeView(String,LinkOption[]) getFileAttributeView(String,LinkOption[])}
|
||||
* method may be used to obtain a file attribute view where dynamic access to
|
||||
* file attributes where required.
|
||||
*
|
||||
* <p> A {@code FileRef} is immutable and safe for use by multiple concurrent
|
||||
* threads.
|
||||
* open the file for reading or writing. It also provides access to associated
|
||||
* metadata or file attributes.
|
||||
*
|
||||
* @since 1.7
|
||||
* @see java.io.Inputs
|
||||
* @see java.io.Outputs
|
||||
* @see java.nio.file.attribute.Attributes
|
||||
* @see java.io.File#toPath
|
||||
*/
|
||||
|
||||
public interface FileRef {
|
||||
|
||||
/**
|
||||
* Opens the file referenced by this object, returning a seekable byte
|
||||
* channel to access the file.
|
||||
* Opens the file referenced by this object, returning an input stream to
|
||||
* read from the file. The stream will not be buffered, and is not required
|
||||
* to support the {@link InputStream#mark mark} or {@link InputStream#reset
|
||||
* reset} methods. The stream will be safe for access by multiple concurrent
|
||||
* threads. Reading commences at the beginning of the file.
|
||||
*
|
||||
* <p> The {@code options} parameter determines how the file is opened.
|
||||
* The {@link StandardOpenOption#READ READ} and {@link StandardOpenOption#WRITE
|
||||
* WRITE} options determine if the file should be opened for reading and/or
|
||||
* writing. If neither option (or the {@link StandardOpenOption#APPEND APPEND}
|
||||
* option) is contained in the array then the file is opened for reading.
|
||||
* By default reading or writing commences at the beginning of the file.
|
||||
* If no options are present then it is equivalent to opening the file with
|
||||
* the {@link StandardOpenOption#READ READ} option. In addition to the {@code
|
||||
* READ} option, an implementation may also support additional implementation
|
||||
* specific options.
|
||||
*
|
||||
* <p> In the addition to {@code READ} and {@code WRITE}, the following
|
||||
* options may be present:
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="">
|
||||
* <tr> <th>Option</th> <th>Description</th> </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#APPEND APPEND} </td>
|
||||
* <td> If this option is present then the file is opened for writing and
|
||||
* each invocation of the channel's {@code write} method first advances
|
||||
* the position to the end of the file and then writes the requested
|
||||
* data. Whether the advancement of the position and the writing of the
|
||||
* data are done in a single atomic operation is system-dependent and
|
||||
* therefore unspecified. This option may not be used in conjunction
|
||||
* with the {@code READ} or {@code TRUNCATE_EXISTING} options. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#TRUNCATE_EXISTING TRUNCATE_EXISTING} </td>
|
||||
* <td> If this option is present then the existing file is truncated to
|
||||
* a size of 0 bytes. This option is ignored when the file is opened only
|
||||
* for reading. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#SYNC SYNC} </td>
|
||||
* <td> Requires that every update to the file's content or metadata be
|
||||
* written synchronously to the underlying storage device. (see <a
|
||||
* href="package-summary.html#integrity"> Synchronized I/O file
|
||||
* integrity</a>). </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link StandardOpenOption#DSYNC DSYNC} </td>
|
||||
* <td> Requires that every update to the file's content be written
|
||||
* synchronously to the underlying storage device. (see <a
|
||||
* href="package-summary.html#integrity"> Synchronized I/O file
|
||||
* integrity</a>). </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p> An implementation of this interface may support additional options
|
||||
* defined by the {@link StandardOpenOption} enumeration type or other
|
||||
* implementation specific options.
|
||||
*
|
||||
* <p> The {@link java.nio.channels.Channels} utility classes defines methods
|
||||
* to construct input and output streams where inter-operation with the
|
||||
* {@link java.io} package is required.
|
||||
*
|
||||
* @param options
|
||||
* Options specifying how the file is opened
|
||||
*
|
||||
* @return a new seekable byte channel
|
||||
* @return an input stream to read bytes from the file
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If an invalid combination of options is specified
|
||||
* if an invalid combination of options is specified
|
||||
* @throws UnsupportedOperationException
|
||||
* If an unsupported open option is specified
|
||||
* if an unsupported option is specified
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the path if the file is
|
||||
* opened for reading. The {@link SecurityManager#checkWrite(String)
|
||||
* checkWrite} method is invoked to check write access to the path
|
||||
* if the file is opened for writing.
|
||||
* method is invoked to check read access to the file.
|
||||
*/
|
||||
SeekableByteChannel newByteChannel(OpenOption... options)
|
||||
throws IOException;
|
||||
InputStream newInputStream(OpenOption... options) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the {@link FileStore} representing the file store where the file
|
||||
* referenced by this object is stored.
|
||||
* Opens or creates the file located by this object for writing, returning
|
||||
* an output stream to write bytes to the file.
|
||||
*
|
||||
* <p> Once a reference to the {@code FileStore} is obtained it is
|
||||
* implementation specific if operations on the returned {@code FileStore},
|
||||
* or {@link FileStoreAttributeView} objects obtained from it, continue
|
||||
* to depend on the existence of the file. In particular the behavior is not
|
||||
* defined for the case that the file is deleted or moved to a different
|
||||
* file store.
|
||||
* <p> The {@code options} parameter determines how the file is opened.
|
||||
* If no options are present then this method creates a new file for writing
|
||||
* or truncates an existing file. In addition to the {@link StandardOpenOption
|
||||
* standard} options, an implementation may also support additional
|
||||
* implementation specific options.
|
||||
*
|
||||
* @return The file store where the file is stored
|
||||
* <p> The resulting stream will not be buffered. The stream will be safe
|
||||
* for access by multiple concurrent threads.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the file, and in
|
||||
* addition it checks {@link RuntimePermission}<tt>
|
||||
* ("getFileStoreAttributes")</tt>
|
||||
*/
|
||||
FileStore getFileStore() throws IOException;
|
||||
|
||||
/**
|
||||
* Checks the existence and optionally the accessibility of the file
|
||||
* referenced by this object.
|
||||
* @param options
|
||||
* options specifying how the file is opened
|
||||
*
|
||||
* <p> This method checks the existence of a file and that this Java virtual
|
||||
* machine has appropriate privileges that would allow it access the file
|
||||
* according to all of access modes specified in the {@code modes} parameter
|
||||
* as follows:
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="">
|
||||
* <tr> <th>Value</th> <th>Description</th> </tr>
|
||||
* <tr>
|
||||
* <td> {@link AccessMode#READ READ} </td>
|
||||
* <td> Checks that the file exists and that the Java virtual machine has
|
||||
* permission to read the file. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link AccessMode#WRITE WRITE} </td>
|
||||
* <td> Checks that the file exists and that the Java virtual machine has
|
||||
* permission to write to the file, </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link AccessMode#EXECUTE EXECUTE} </td>
|
||||
* <td> Checks that the file exists and that the Java virtual machine has
|
||||
* permission to {@link Runtime#exec execute} the file. The semantics
|
||||
* may differ when checking access to a directory. For example, on UNIX
|
||||
* systems, checking for {@code EXECUTE} access checks that the Java
|
||||
* virtual machine has permission to search the directory in order to
|
||||
* access file or subdirectories. </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p> If the {@code modes} parameter is of length zero, then the existence
|
||||
* of the file is checked.
|
||||
*
|
||||
* <p> This method follows symbolic links if the file referenced by this
|
||||
* object is a symbolic link. Depending on the implementation, this method
|
||||
* may require to read file permissions, access control lists, or other
|
||||
* file attributes in order to check the effective access to the file. To
|
||||
* determine the effective access to a file may require access to several
|
||||
* attributes and so in some implementations this method may not be atomic
|
||||
* with respect to other file system operations. Furthermore, as the result
|
||||
* of this method is immediately outdated, there is no guarantee that a
|
||||
* subsequence access will succeed (or even that it will access the same
|
||||
* file). Care should be taken when using this method in security sensitive
|
||||
* applications.
|
||||
*
|
||||
* @param modes
|
||||
* The access modes to check; may have zero elements
|
||||
* @return a new output stream
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code options} contains an invalid combination of options
|
||||
* @throws UnsupportedOperationException
|
||||
* An implementation is required to support checking for
|
||||
* {@code READ}, {@code WRITE}, and {@code EXECUTE} access. This
|
||||
* exception is specified to allow for the {@code Access} enum to
|
||||
* be extended in future releases.
|
||||
* @throws NoSuchFileException
|
||||
* If a file does not exist <i>(optional specific exception)</i>
|
||||
* @throws AccessDeniedException
|
||||
* The requested access would be denied or the access cannot be
|
||||
* determined because the Java virtual machine has insufficient
|
||||
* privileges or other reasons. <i>(optional specific exception)</i>
|
||||
* if an unsupported option is specified
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* is invoked when checking read access to the file or only the
|
||||
* existence of the file, the {@link SecurityManager#checkWrite(String)
|
||||
* checkWrite} is invoked when checking write access to the file,
|
||||
* and {@link SecurityManager#checkExec(String) checkExec} is invoked
|
||||
* when checking execute access.
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method is invoked to check write access to the file.
|
||||
*/
|
||||
void checkAccess(AccessMode... modes) throws IOException;
|
||||
OutputStream newOutputStream(OpenOption... options) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a file attribute view of a given type.
|
||||
@ -266,11 +126,11 @@ public interface FileRef {
|
||||
* that do not support symbolic links.
|
||||
*
|
||||
* @param type
|
||||
* The {@code Class} object corresponding to the file attribute view
|
||||
* the {@code Class} object corresponding to the file attribute view
|
||||
* @param options
|
||||
* Options indicating how symbolic links are handled
|
||||
* options indicating how symbolic links are handled
|
||||
*
|
||||
* @return A file attribute view of the specified type, or {@code null} if
|
||||
* @return a file attribute view of the specified type, or {@code null} if
|
||||
* the attribute view type is not available
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
@ -280,145 +140,185 @@ public interface FileRef {
|
||||
*
|
||||
* @see Attributes#readBasicFileAttributes
|
||||
*/
|
||||
<V extends FileAttributeView> V getFileAttributeView(Class<V> type, LinkOption... options);
|
||||
<V extends FileAttributeView> V getFileAttributeView(Class<V> type,
|
||||
LinkOption... options);
|
||||
|
||||
/**
|
||||
* Returns a file attribute view of the given name.
|
||||
* Sets the value of a file attribute.
|
||||
*
|
||||
* <p> A file attribute view provides a read-only or updatable view of a
|
||||
* set of file attributes. This method is intended to be used where
|
||||
* <em>dynamic access</em> to the file attributes is required. The {@code
|
||||
* name} parameter specifies the {@link FileAttributeView#name name} of the
|
||||
* file attribute view and this method returns an instance of that view if
|
||||
* supported. The {@link BasicFileAttributeView} type supports access to the
|
||||
* basic attributes of a file and is name {@code "basic"}. Invoking this
|
||||
* method to select a file attribute view named {@code "basic"} will always
|
||||
* return an instance of that class.
|
||||
* <p> The {@code attribute} parameter identifies the attribute to be set
|
||||
* and takes the form:
|
||||
* <blockquote>
|
||||
* [<i>view-name</i><b>:</b>]<i>attribute-name</i>
|
||||
* </blockquote>
|
||||
* where square brackets [...] delineate an optional component and the
|
||||
* character {@code ':'} stands for itself.
|
||||
*
|
||||
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
|
||||
* FileAttributeView} that identifies a set of file attributes. If not
|
||||
* specified then it defaults to {@code "basic"}, the name of the file
|
||||
* attribute view that identifies the basic set of file attributes common to
|
||||
* many file systems. <i>attribute-name</i> is the name of the attribute
|
||||
* within the set.
|
||||
*
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we want to set the DOS "hidden" attribute:
|
||||
* <pre>
|
||||
* file.setAttribute("dos:hidden", true);
|
||||
* </pre>
|
||||
*
|
||||
* @param attribute
|
||||
* the attribute to set
|
||||
* @param value
|
||||
* the attribute value
|
||||
* @param options
|
||||
* options indicating how symbolic links are handled
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* if the attribute view is not available or it does not support
|
||||
* updating the attribute
|
||||
* @throws IllegalArgumentException
|
||||
* if the attribute value is of the correct type but has an
|
||||
* inappropriate value
|
||||
* @throws ClassCastException
|
||||
* If the attribute value is not of the expected type or is a
|
||||
* collection containing elements that are not of the expected
|
||||
* type
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, its {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method denies write access to the file. If this method is invoked
|
||||
* to set security sensitive attributes then the security manager
|
||||
* may be invoked to check for additional permissions.
|
||||
*/
|
||||
void setAttribute(String attribute, Object value, LinkOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Reads the value of a file attribute.
|
||||
*
|
||||
* <p> The {@code attribute} parameter identifies the attribute to be read
|
||||
* and takes the form:
|
||||
* <blockquote>
|
||||
* [<i>view-name</i><b>:</b>]<i>attribute-name</i>
|
||||
* </blockquote>
|
||||
* where square brackets [...] delineate an optional component and the
|
||||
* character {@code ':'} stands for itself.
|
||||
*
|
||||
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
|
||||
* FileAttributeView} that identifies a set of file attributes. If not
|
||||
* specified then it defaults to {@code "basic"}, the name of the file
|
||||
* attribute view that identifies the basic set of file attributes common to
|
||||
* many file systems. <i>attribute-name</i> is the name of the attribute.
|
||||
*
|
||||
* <p> The {@code options} array may be used to indicate how symbolic links
|
||||
* are handled by the resulting file attribute view for the case that the
|
||||
* file is a symbolic link. By default, symbolic links are followed. If the
|
||||
* option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is present then
|
||||
* symbolic links are not followed. This option is ignored by implementations
|
||||
* that do not support symbolic links.
|
||||
* are handled for the case that the file is a symbolic link. By default,
|
||||
* symbolic links are followed and the file attribute of the final target
|
||||
* of the link is read. If the option {@link LinkOption#NOFOLLOW_LINKS
|
||||
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
|
||||
* the method returns the file attribute of the symbolic link.
|
||||
*
|
||||
* @param name
|
||||
* The name of the file attribute view
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we require the user ID of the file owner on a system that
|
||||
* supports a "{@code unix}" view:
|
||||
* <pre>
|
||||
* int uid = (Integer)file.getAttribute("unix:uid");
|
||||
* </pre>
|
||||
*
|
||||
* @param attribute
|
||||
* the attribute to read
|
||||
* @param options
|
||||
* options indicating how symbolic links are handled
|
||||
* @return the attribute value or {@code null} if the attribute view
|
||||
* is not available or it does not support reading the attribute
|
||||
*
|
||||
* reading the attribute
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, its {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method denies read access to the file. If this method is invoked
|
||||
* to read security sensitive attributes then the security manager
|
||||
* may be invoked to check for additional permissions.
|
||||
*/
|
||||
Object getAttribute(String attribute, LinkOption... options) throws IOException;
|
||||
|
||||
/**
|
||||
* Reads a set of file attributes as a bulk operation.
|
||||
*
|
||||
* <p> The {@code attributes} parameter identifies the attributes to be read
|
||||
* and takes the form:
|
||||
* <blockquote>
|
||||
* [<i>view-name</i><b>:</b>]<i>attribute-list</i>
|
||||
* </blockquote>
|
||||
* where square brackets [...] delineate an optional component and the
|
||||
* character {@code ':'} stands for itself.
|
||||
*
|
||||
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
|
||||
* FileAttributeView} that identifies a set of file attributes. If not
|
||||
* specified then it defaults to {@code "basic"}, the name of the file
|
||||
* attribute view that identifies the basic set of file attributes common to
|
||||
* many file systems.
|
||||
*
|
||||
* <p> The <i>attribute-list</i> component is a comma separated list of
|
||||
* zero or more names of attributes to read. If the list contains the value
|
||||
* {@code "*"} then all attributes are read. Attributes that are not supported
|
||||
* are ignored and will not be present in the returned map. It is
|
||||
* implementation specific if all attributes are read as an atomic operation
|
||||
* with respect to other file system operations.
|
||||
*
|
||||
* <p> The following examples demonstrate possible values for the {@code
|
||||
* attributes} parameter:
|
||||
*
|
||||
* <blockquote>
|
||||
* <table border="0">
|
||||
* <tr>
|
||||
* <td> {@code "*"} </td>
|
||||
* <td> Read all {@link BasicFileAttributes basic-file-attributes}. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code "size,lastModifiedTime,lastAccessTime"} </td>
|
||||
* <td> Reads the file size, last modified time, and last access time
|
||||
* attributes. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code "posix:*"} </td>
|
||||
* <td> Read all {@link PosixFileAttributes POSIX-file-attributes}.. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code "posix:permissions,owner,size"} </td>
|
||||
* <td> Reads the POSX file permissions, owner, and file size. </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> The {@code options} array may be used to indicate how symbolic links
|
||||
* are handled for the case that the file is a symbolic link. By default,
|
||||
* symbolic links are followed and the file attribute of the final target
|
||||
* of the link is read. If the option {@link LinkOption#NOFOLLOW_LINKS
|
||||
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
|
||||
* the method returns the file attribute of the symbolic link.
|
||||
*
|
||||
* @param attributes
|
||||
* The attributes to read
|
||||
* @param options
|
||||
* Options indicating how symbolic links are handled
|
||||
*
|
||||
* @return A file attribute view of the given name, or {@code null} if
|
||||
* the attribute view is not available
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* If options contains an unsupported option. This exception is
|
||||
* specified to allow the {@code LinkOption} enum be extended
|
||||
* in future releases.
|
||||
*/
|
||||
FileAttributeView getFileAttributeView(String name, LinkOption... options);
|
||||
|
||||
/**
|
||||
* Tests if the file referenced by this object is the same file referenced
|
||||
* by another object.
|
||||
*
|
||||
* <p> If this {@code FileRef} and the given {@code FileRef} are {@link
|
||||
* #equals(Object) equal} then this method returns {@code true} without checking
|
||||
* if the file exists. If the {@code FileRef} and the given {@code FileRef}
|
||||
* are associated with different providers, or the given {@code FileRef} is
|
||||
* {@code null} then this method returns {@code false}. Otherwise, this method
|
||||
* checks if both {@code FileRefs} locate the same file, and depending on the
|
||||
* implementation, may require to open or access both files.
|
||||
*
|
||||
* <p> If the file system and files remain static, then this method implements
|
||||
* an equivalence relation for non-null {@code FileRefs}.
|
||||
* <ul>
|
||||
* <li>It is <i>reflexive</i>: for a non-null {@code FileRef} {@code f},
|
||||
* {@code f.isSameFile(f)} should return {@code true}.
|
||||
* <li>It is <i>symmetric</i>: for two non-null {@code FileRefs}
|
||||
* {@code f} and {@code g}, {@code f.isSameFile(g)} will equal
|
||||
* {@code g.isSameFile(f)}.
|
||||
* <li>It is <i>transitive</i>: for three {@code FileRefs}
|
||||
* {@code f}, {@code g}, and {@code h}, if {@code f.isSameFile(g)} returns
|
||||
* {@code true} and {@code g.isSameFile(h)} returns {@code true}, then
|
||||
* {@code f.isSameFile(h)} will return return {@code true}.
|
||||
* </ul>
|
||||
*
|
||||
* @param other
|
||||
* The other file reference
|
||||
*
|
||||
* @return {@code true} if, and only if, this object and the given object
|
||||
* locate the same file
|
||||
* @return A map of the attributes returned; may be empty. The map's keys
|
||||
* are the attribute names, its values are the attribute values
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to both files.
|
||||
*
|
||||
* @see java.nio.file.attribute.BasicFileAttributes#fileKey
|
||||
* installed, its {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method denies read access to the file. If this method is invoked
|
||||
* to read security sensitive attributes then the security manager
|
||||
* may be invoke to check for additional permissions.
|
||||
*/
|
||||
boolean isSameFile(FileRef other) throws IOException;
|
||||
|
||||
/**
|
||||
* Deletes the file referenced by this object.
|
||||
*
|
||||
* <p> An implementation may require to examine the file to determine if the
|
||||
* file is a directory. Consequently this method may not be atomic with respect
|
||||
* to other file system operations. If the file is a symbolic-link then the
|
||||
* link is deleted and not the final target of the link.
|
||||
*
|
||||
* <p> If the file is a directory then the directory must be empty. In some
|
||||
* implementations a directory has entries for special files or links that
|
||||
* are created when the directory is created. In such implementations a
|
||||
* directory is considered empty when only the special entries exist.
|
||||
*
|
||||
* <p> On some operating systems it may not be possible to remove a file when
|
||||
* it is open and in use by this Java virtual machine or other programs.
|
||||
*
|
||||
* @throws NoSuchFileException
|
||||
* If the file does not exist <i>(optional specific exception)</i>
|
||||
* @throws DirectoryNotEmptyException
|
||||
* If the file is a directory and could not otherwise be deleted
|
||||
* because the directory is not empty <i>(optional specific
|
||||
* exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkDelete(String)} method
|
||||
* is invoked to check delete access to the file
|
||||
*/
|
||||
void delete() throws IOException;
|
||||
|
||||
/**
|
||||
* Tests this object for equality with another object.
|
||||
*
|
||||
* <p> If the given object is not a {@code FileRef} then this method
|
||||
* immediately returns {@code false}.
|
||||
*
|
||||
* <p> For two file references to be considered equal requires that they
|
||||
* are both the same type of {@code FileRef} and encapsulate components
|
||||
* to locate the same file. This method does not access the file system and
|
||||
* the file may not exist.
|
||||
*
|
||||
* <p> This method satisfies the general contract of the {@link
|
||||
* java.lang.Object#equals(Object) Object.equals} method. </p>
|
||||
*
|
||||
* @param ob The object to which this object is to be compared
|
||||
*
|
||||
* @return {@code true} if, and only if, the given object is a {@code FileRef}
|
||||
* that is identical to this {@code FileRef}
|
||||
*
|
||||
* @see #isSameFile
|
||||
*/
|
||||
boolean equals(Object ob);
|
||||
|
||||
/**
|
||||
* Returns the hash-code value for this object.
|
||||
*
|
||||
* <p> This method satisfies the general contract of the
|
||||
* {@link java.lang.Object#hashCode() Object.hashCode} method.
|
||||
*/
|
||||
int hashCode();
|
||||
Map<String,?> readAttributes(String attributes, LinkOption... options)
|
||||
throws IOException;
|
||||
}
|
||||
|
||||
@ -26,12 +26,13 @@
|
||||
package java.nio.file;
|
||||
|
||||
import java.nio.file.attribute.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Storage for files. A {@code FileStore} represents a storage pool, device,
|
||||
* partition, volume, concrete file system or other implementation specific means
|
||||
* of file storage. The {@code FileStore} for where a file is stored is obtained
|
||||
* by invoking the {@link FileRef#getFileStore getFileStore} method, or all file
|
||||
* by invoking the {@link Path#getFileStore getFileStore} method, or all file
|
||||
* stores can be enumerated by invoking the {@link FileSystem#getFileStores
|
||||
* getFileStores} method.
|
||||
*
|
||||
@ -146,24 +147,41 @@ public abstract class FileStore {
|
||||
getFileStoreAttributeView(Class<V> type);
|
||||
|
||||
/**
|
||||
* Returns a {@code FileStoreAttributeView} of the given name.
|
||||
* Reads the value of a file store attribute.
|
||||
*
|
||||
* <p> This method is intended to be used where <em>dynamic access</em> to
|
||||
* file store attributes is required. The {@code name} parameter specifies
|
||||
* the {@link FileAttributeView#name name} of the file store attribute view
|
||||
* and this method returns an instance of that view if supported.
|
||||
* <p> The {@code attribute} parameter identifies the attribute to be read
|
||||
* and takes the form:
|
||||
* <blockquote>
|
||||
* <i>view-name</i><b>:</b><i>attribute-name</i>
|
||||
* </blockquote>
|
||||
* where the character {@code ':'} stands for itself.
|
||||
*
|
||||
* <p> <i>view-name</i> is the {@link FileStoreAttributeView#name name} of
|
||||
* a {@link FileStore AttributeView} that identifies a set of file attributes.
|
||||
* <i>attribute-name</i> is the name of the attribute.
|
||||
*
|
||||
* <p> For {@code FileStore} objects created by the default provider, then
|
||||
* the file stores support the {@link FileStoreSpaceAttributeView} that
|
||||
* provides access to space attributes. In that case invoking this method
|
||||
* with a parameter value of {@code "space"} will always return an instance
|
||||
* of that class.
|
||||
* provides access to space attributes.
|
||||
*
|
||||
* @param name
|
||||
* the name of the attribute view
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we want to know if ZFS compression is enabled (assuming the "zfs"
|
||||
* view is supported):
|
||||
* <pre>
|
||||
* boolean compression = (Boolean)fs.getAttribute("zfs:compression");
|
||||
* </pre>
|
||||
*
|
||||
* @return a file store attribute view of the given name, or {@code null}
|
||||
* if the attribute view is not available
|
||||
* @param attribute
|
||||
* the attribute to read
|
||||
|
||||
* @return the attribute value; {@code null} may be a valid valid for some
|
||||
* attributes
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* if the attribute view is not available or it does not support
|
||||
* reading the attribute
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
*/
|
||||
public abstract FileStoreAttributeView getFileStoreAttributeView(String name);
|
||||
public abstract Object getAttribute(String attribute) throws IOException;
|
||||
}
|
||||
|
||||
@ -50,8 +50,6 @@ class FileTreeWalker {
|
||||
case FOLLOW_LINKS : fl = true; break;
|
||||
case DETECT_CYCLES : dc = true; break;
|
||||
default:
|
||||
if (option == null)
|
||||
throw new NullPointerException("Visit options contains 'null'");
|
||||
throw new AssertionError("Should not get here");
|
||||
}
|
||||
}
|
||||
@ -239,13 +237,13 @@ class FileTreeWalker {
|
||||
}
|
||||
|
||||
private static class AncestorDirectory {
|
||||
private final FileRef dir;
|
||||
private final Path dir;
|
||||
private final Object key;
|
||||
AncestorDirectory(FileRef dir, Object key) {
|
||||
AncestorDirectory(Path dir, Object key) {
|
||||
this.dir = dir;
|
||||
this.key = key;
|
||||
}
|
||||
FileRef file() {
|
||||
Path file() {
|
||||
return dir;
|
||||
}
|
||||
Object fileKey() {
|
||||
|
||||
@ -42,9 +42,9 @@ import java.io.IOException;
|
||||
* @Override
|
||||
* public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
* try {
|
||||
* file.delete(false);
|
||||
* file.delete();
|
||||
* } catch (IOException exc) {
|
||||
* // failed to delete
|
||||
* // failed to delete, do error handling here
|
||||
* }
|
||||
* return FileVisitResult.CONTINUE;
|
||||
* }
|
||||
@ -52,9 +52,9 @@ import java.io.IOException;
|
||||
* public FileVisitResult postVisitDirectory(Path dir, IOException e) {
|
||||
* if (e == null) {
|
||||
* try {
|
||||
* dir.delete(false);
|
||||
* dir.delete();
|
||||
* } catch (IOException exc) {
|
||||
* // failed to delete
|
||||
* // failed to delete, do error handling here
|
||||
* }
|
||||
* } else {
|
||||
* // directory iteration failed
|
||||
@ -80,7 +80,8 @@ import java.io.IOException;
|
||||
* } catch (FileAlreadyExistsException e) {
|
||||
* // ignore
|
||||
* } catch (IOException e) {
|
||||
* // copy failed, skip rest of directory and descendants
|
||||
* // copy failed, do error handling here
|
||||
* // skip rest of directory and descendants
|
||||
* return SKIP_SUBTREE;
|
||||
* }
|
||||
* return CONTINUE;
|
||||
@ -90,7 +91,7 @@ import java.io.IOException;
|
||||
* try {
|
||||
* file.copyTo(target.resolve(source.relativize(file)));
|
||||
* } catch (IOException e) {
|
||||
* // copy failed
|
||||
* // copy failed, do error handling here
|
||||
* }
|
||||
* return CONTINUE;
|
||||
* }
|
||||
@ -100,7 +101,7 @@ import java.io.IOException;
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public interface FileVisitor<T extends FileRef> {
|
||||
public interface FileVisitor<T> {
|
||||
|
||||
/**
|
||||
* Invoked for a directory before entries in the directory are visited.
|
||||
|
||||
@ -26,13 +26,15 @@
|
||||
package java.nio.file;
|
||||
|
||||
import java.nio.file.spi.FileTypeDetector;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* Utility methods for files and directories.
|
||||
* This class consists exclusively of static methods that operate on files or
|
||||
* directories.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
@ -109,8 +111,6 @@ public final class Files {
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an unspecified
|
||||
* permission required by a file type detector implementation.
|
||||
*
|
||||
* @see DirectoryStreamFilters#newContentTypeFilter
|
||||
*/
|
||||
public static String probeContentType(FileRef file)
|
||||
throws IOException
|
||||
@ -127,158 +127,6 @@ public final class Files {
|
||||
.probeContentType(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a {@link FileAction} for each entry in a directory accepted
|
||||
* by a given {@link java.nio.file.DirectoryStream.Filter filter}.
|
||||
*
|
||||
* <p> This method opens the given directory and invokes the file action's
|
||||
* {@link FileAction#invoke invoke} method for each entry accepted by the
|
||||
* filter. When iteration is completed then the directory is closed. If the
|
||||
* {@link DirectoryStream#close close} method throws an {@code IOException}
|
||||
* then it is silently ignored.
|
||||
*
|
||||
* <p> If the {@code FileAction}'s {@code invoke} method terminates due
|
||||
* to an uncaught {@link IOException}, {@code Error} or {@code RuntimeException}
|
||||
* then the exception is propagated by this method after closing the
|
||||
* directory.
|
||||
*
|
||||
* @param dir
|
||||
* The directory
|
||||
* @param filter
|
||||
* The filter
|
||||
* @param action
|
||||
* The {@code FileAction} to invoke for each accepted entry
|
||||
*
|
||||
* @throws NotDirectoryException
|
||||
* If the {@code dir} parameter is not a directory <i>(optional
|
||||
* specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs or the {@code invoke} method terminates
|
||||
* due to an uncaught {@code IOException}
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, the {@link
|
||||
* SecurityManager#checkRead(String) checkRead} method is invoked
|
||||
* to check read access to the directory.
|
||||
*/
|
||||
public static void withDirectory(Path dir,
|
||||
DirectoryStream.Filter<? super Path> filter,
|
||||
FileAction<? super Path> action)
|
||||
throws IOException
|
||||
{
|
||||
// explicit null check required in case directory is empty
|
||||
if (action == null)
|
||||
throw new NullPointerException();
|
||||
|
||||
DirectoryStream<Path> stream = dir.newDirectoryStream(filter);
|
||||
try {
|
||||
// set to true when invoking the action so as to distinguish a
|
||||
// CME thrown by the iteration from a CME thrown by the invoke
|
||||
boolean inAction = false;
|
||||
try {
|
||||
for (Path entry: stream) {
|
||||
inAction = true;
|
||||
action.invoke(entry);
|
||||
inAction = false;
|
||||
}
|
||||
} catch (ConcurrentModificationException cme) {
|
||||
if (!inAction) {
|
||||
Throwable cause = cme.getCause();
|
||||
if (cause instanceof IOException)
|
||||
throw (IOException)cause;
|
||||
}
|
||||
throw cme;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException x) { }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a {@link FileAction} for each entry in a directory with a
|
||||
* file name that matches a given pattern.
|
||||
*
|
||||
* <p> This method opens the given directory and invokes the file action's
|
||||
* {@link FileAction#invoke invoke} method for each entry that matches the
|
||||
* given pattern. When iteration is completed then the directory is closed.
|
||||
* If the {@link DirectoryStream#close close} method throws an {@code
|
||||
* IOException} then it is silently ignored.
|
||||
*
|
||||
* <p> If the {@code FileAction}'s {@code invoke} method terminates due
|
||||
* to an uncaught {@link IOException}, {@code Error} or {@code RuntimeException}
|
||||
* then the exception is propagated by this method after closing the
|
||||
* directory.
|
||||
*
|
||||
* <p> The globbing pattern language supported by this method is as
|
||||
* specified by the {@link FileSystem#getPathMatcher getPathMatcher} method.
|
||||
*
|
||||
* @param dir
|
||||
* The directory
|
||||
* @param glob
|
||||
* The globbing pattern
|
||||
* @param action
|
||||
* The {@code FileAction} to invoke for each entry
|
||||
*
|
||||
* @throws NotDirectoryException
|
||||
* If the {@code dir} parameter is not a directory <i>(optional
|
||||
* specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs or the {@code invoke} method terminates
|
||||
* due to an uncaught {@code IOException}
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, the {@link
|
||||
* SecurityManager#checkRead(String) checkRead} method is invoked
|
||||
* to check read access to the directory.
|
||||
*/
|
||||
public static void withDirectory(Path dir,
|
||||
String glob,
|
||||
FileAction<? super Path> action)
|
||||
throws IOException
|
||||
{
|
||||
if (glob == null)
|
||||
throw new NullPointerException("'glob' is null");
|
||||
final PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:" + glob);
|
||||
DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
|
||||
@Override
|
||||
public boolean accept(Path entry) {
|
||||
return matcher.matches(entry.getName());
|
||||
}
|
||||
};
|
||||
withDirectory(dir, filter, action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a {@link FileAction} for all entries in a directory.
|
||||
*
|
||||
* <p> This method works as if invoking it were equivalent to evaluating the
|
||||
* expression:
|
||||
* <blockquote><pre>
|
||||
* withDirectory(dir, "*", action)
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @param dir
|
||||
* The directory
|
||||
* @param action
|
||||
* The {@code FileAction} to invoke for each entry
|
||||
*
|
||||
* @throws NotDirectoryException
|
||||
* If the {@code dir} parameter is not a directory <i>(optional
|
||||
* specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs or the {@code invoke} method terminates
|
||||
* due to an uncaught {@code IOException}
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, the {@link
|
||||
* SecurityManager#checkRead(String) checkRead} method is invoked
|
||||
* to check read access to the directory.
|
||||
*/
|
||||
public static void withDirectory(Path dir, FileAction<? super Path> action)
|
||||
throws IOException
|
||||
{
|
||||
withDirectory(dir, "*", action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks a file tree.
|
||||
*
|
||||
@ -328,7 +176,7 @@ public final class Files {
|
||||
* arises when there is an entry in a directory that is an ancestor of the
|
||||
* directory. Cycle detection is done by recording the {@link
|
||||
* java.nio.file.attribute.BasicFileAttributes#fileKey file-key} of directories,
|
||||
* or if file keys are not available, by invoking the {@link FileRef#isSameFile
|
||||
* or if file keys are not available, by invoking the {@link Path#isSameFile
|
||||
* isSameFile} method to test if a directory is the same file as an
|
||||
* ancestor. When a cycle is detected the {@link FileVisitor#visitFile
|
||||
* visitFile} is invoked with the attributes of the directory. The {@link
|
||||
@ -403,4 +251,108 @@ public final class Files {
|
||||
Integer.MAX_VALUE,
|
||||
visitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a directory by creating all nonexistent parent directories first.
|
||||
*
|
||||
* <p> The {@code attrs} parameter is an optional array of {@link FileAttribute
|
||||
* file-attributes} to set atomically when creating the nonexistent
|
||||
* directories. Each file attribute is identified by its {@link
|
||||
* FileAttribute#name name}. If more than one attribute of the same name is
|
||||
* included in the array then all but the last occurrence is ignored.
|
||||
*
|
||||
* <p> If this method fails, then it may do so after creating some, but not
|
||||
* all, of the parent directories.
|
||||
*
|
||||
* @param dir
|
||||
* the directory to create
|
||||
*
|
||||
* @param attrs
|
||||
* an optional list of file attributes to set atomically when
|
||||
* creating the directory
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* if the array contains an attribute that cannot be set atomically
|
||||
* when creating the directory
|
||||
* @throws FileAlreadyExistsException
|
||||
* if {@code dir} exists but is not a directory <i>(optional specific
|
||||
* exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* in the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method is invoked prior to attempting to create a directory and
|
||||
* its {@link SecurityManager#checkRead(String) checkRead} is
|
||||
* invoked for each parent directory that is checked. If {@code
|
||||
* dir} is not an absolute path then its {@link Path#toAbsolutePath
|
||||
* toAbsolutePath} may need to be invoked to get its absolute path.
|
||||
* This may invoke the security manager's {@link
|
||||
* SecurityManager#checkPropertyAccess(String) checkPropertyAccess}
|
||||
* method to check access to the system property {@code user.dir}
|
||||
*
|
||||
*/
|
||||
public static void createDirectories(Path dir, FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
// attempt to create the directory
|
||||
try {
|
||||
createAndCheckIsDirectory(dir, attrs);
|
||||
return;
|
||||
} catch (FileAlreadyExistsException x) {
|
||||
// file exists and is not a directory
|
||||
throw x;
|
||||
} catch (IOException x) {
|
||||
// parent may not exist or other reason
|
||||
}
|
||||
|
||||
// find existing parent (may require absolute path)
|
||||
SecurityException se = null;
|
||||
try {
|
||||
dir = dir.toAbsolutePath();
|
||||
} catch (SecurityException x) {
|
||||
// don't have permission to get absolute path
|
||||
se = x;
|
||||
}
|
||||
Path parent = dir.getParent();
|
||||
while (parent != null) {
|
||||
try {
|
||||
parent.checkAccess();
|
||||
break;
|
||||
} catch (NoSuchFileException x) {
|
||||
// does not exist
|
||||
}
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if (parent == null) {
|
||||
// unable to find existing parent
|
||||
if (se != null)
|
||||
throw se;
|
||||
throw new IOException("Root directory does not exist");
|
||||
}
|
||||
|
||||
// create directories
|
||||
Path child = parent;
|
||||
for (Path name: parent.relativize(dir)) {
|
||||
child = child.resolve(name);
|
||||
createAndCheckIsDirectory(child, attrs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to create a directory. Does nothing if the directory already
|
||||
* exists.
|
||||
*/
|
||||
private static void createAndCheckIsDirectory(Path dir, FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
try {
|
||||
dir.createDirectory(attrs);
|
||||
} catch (FileAlreadyExistsException x) {
|
||||
boolean isDirectory = Attributes
|
||||
.readBasicFileAttributes(dir, LinkOption.NOFOLLOW_LINKS).isDirectory();
|
||||
if (!isDirectory)
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public final class LinkPermission extends BasicPermission {
|
||||
* {@code null}
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if name is empty or invalid
|
||||
* if name is empty or invalid, or actions is a non-empty string
|
||||
*/
|
||||
public LinkPermission(String name, String actions) {
|
||||
super(name);
|
||||
|
||||
@ -30,7 +30,7 @@ package java.nio.file;
|
||||
*
|
||||
* <p> Objects of this type are used by methods such as {@link
|
||||
* Path#newOutputStream(OpenOption[]) newOutputStream}, {@link
|
||||
* FileRef#newByteChannel newByteChannel}, {@link
|
||||
* Path#newByteChannel newByteChannel}, {@link
|
||||
* java.nio.channels.FileChannel#open FileChannel.open}, and {@link
|
||||
* java.nio.channels.AsynchronousFileChannel#open AsynchronousFileChannel.open}
|
||||
* when opening or creating a file.
|
||||
|
||||
@ -26,10 +26,12 @@
|
||||
package java.nio.file;
|
||||
|
||||
import java.nio.file.attribute.*;
|
||||
import java.nio.channels.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.SeekableByteChannel;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.*;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A file reference that locates a file using a system dependent path. The file
|
||||
@ -70,19 +72,27 @@ import java.util.*;
|
||||
* this class defines the following operations:
|
||||
*
|
||||
* <ul>
|
||||
* <li><p> The {@link #newByteChannel newByteChannel} method
|
||||
* may be used to open a file and obtain a byte channel for reading or
|
||||
* writing. </p></li>
|
||||
* <li><p> Files may be {@link #createFile(FileAttribute[]) created}, or
|
||||
* directories may be {@link #createDirectory(FileAttribute[]) created}.
|
||||
* </p></li>
|
||||
* <li><p> The {@link #delete delete} method may be used to delete a file.
|
||||
* </p></li>
|
||||
* <li><p> The {@link #checkAccess checkAccess} method may be used to check
|
||||
* the existence or accessibility of a file. </p></li>
|
||||
* <li><p> The {@link #isSameFile isSameFile} method may be used to test if
|
||||
* two file references locate the same file. </p></li>
|
||||
* <li><p> The {@link #getFileStore getFileStore} method may be used to
|
||||
* obtain the {@link FileStore} representing the storage where a file is
|
||||
* located. </p></li>
|
||||
* <li><p> Directories can be {@link #newDirectoryStream opened} so as to
|
||||
* iterate over the entries in the directory. </p></li>
|
||||
* <li><p> Files can be {@link #copyTo(Path,CopyOption[]) copied} or
|
||||
* {@link #moveTo(Path,CopyOption[]) moved}. </p></li>
|
||||
* <li><p> Symbolic-links may be {@link #createSymbolicLink created}, or the
|
||||
* target of a link may be {@link #readSymbolicLink read}. </p></li>
|
||||
* <li><p> {@link #newInputStream InputStream} or {@link #newOutputStream
|
||||
* OutputStream} streams can be created to allow for interoperation with the
|
||||
* <a href="../../../java/io/package-summary.html">{@code java.io}</a> package
|
||||
* where required. </li></p>
|
||||
* <li><p> The {@link #toRealPath real} path of an existing file may be
|
||||
* obtained. </li></p>
|
||||
* </ul>
|
||||
@ -93,13 +103,14 @@ import java.util.*;
|
||||
*
|
||||
* <h4>File attributes</h4>
|
||||
*
|
||||
* The <a href="attribute/package-summary.html">{@code java.nio.file.attribute}</a>
|
||||
* package provides access to file attributes or <em>meta-data</em> associated
|
||||
* with files. The {@link Attributes Attributes} class defines methods that
|
||||
* operate on or return file attributes. For example, the file type, size,
|
||||
* timestamps, and other <em>basic</em> meta-data are obtained, in bulk, by
|
||||
* invoking the {@link Attributes#readBasicFileAttributes
|
||||
* Attributes.readBasicFileAttributes} method:
|
||||
* In addition to the {@link #setAttribute setAttribute} and {@link #getAttribute
|
||||
* getAttribute} methods, the <a href="attribute/package-summary.html">{@code
|
||||
* java.nio.file.attribute}</a> package provides type-safe and efficient access
|
||||
* to file attributes or <em>meta-data</em> associated with files. The {@link
|
||||
* Attributes Attributes} class defines methods that operate on or return file
|
||||
* attributes. For example, the file type, size, timestamps, and other
|
||||
* <em>basic</em> meta-data are obtained, in bulk, by invoking the {@link
|
||||
* Attributes#readBasicFileAttributes Attributes.readBasicFileAttributes} method:
|
||||
* <pre>
|
||||
* Path file = ...
|
||||
* BasicFileAttributes attrs = Attributes.readBasicFileAttributes(file);
|
||||
@ -417,12 +428,38 @@ public abstract class Path
|
||||
/**
|
||||
* Deletes the file located by this path.
|
||||
*
|
||||
* <p> The {@code failIfNotExists} parameter determines how the method
|
||||
* behaves when the file does not exist. When {@code true}, and the file
|
||||
* does not exist, then the method fails. When {@code false} then the method
|
||||
* does not fail.
|
||||
* <p> An implementation may require to examine the file to determine if the
|
||||
* file is a directory. Consequently this method may not be atomic with respect
|
||||
* to other file system operations. If the file is a symbolic-link then the
|
||||
* link is deleted and not the final target of the link.
|
||||
*
|
||||
* <p> As with the {@link FileRef#delete delete()} method, an implementation
|
||||
* <p> If the file is a directory then the directory must be empty. In some
|
||||
* implementations a directory has entries for special files or links that
|
||||
* are created when the directory is created. In such implementations a
|
||||
* directory is considered empty when only the special entries exist.
|
||||
*
|
||||
* <p> On some operating systems it may not be possible to remove a file when
|
||||
* it is open and in use by this Java virtual machine or other programs.
|
||||
*
|
||||
* @throws NoSuchFileException
|
||||
* if the file does not exist <i>(optional specific exception)</i>
|
||||
* @throws DirectoryNotEmptyException
|
||||
* if the file is a directory and could not otherwise be deleted
|
||||
* because the directory is not empty <i>(optional specific
|
||||
* exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkDelete(String)} method
|
||||
* is invoked to check delete access to the file
|
||||
*/
|
||||
public abstract void delete() throws IOException;
|
||||
|
||||
/**
|
||||
* Deletes the file located by this path, if it exists.
|
||||
*
|
||||
* <p> As with the {@link #delete delete()} method, an implementation
|
||||
* may require to examine the file to determine if the file is a directory.
|
||||
* Consequently this method may not be atomic with respect to other file
|
||||
* system operations. If the file is a symbolic-link then the link is
|
||||
@ -436,13 +473,6 @@ public abstract class Path
|
||||
* <p> On some operating systems it may not be possible to remove a file when
|
||||
* it is open and in use by this Java virtual machine or other programs.
|
||||
*
|
||||
* @param failIfNotExists
|
||||
* {@code true} if the method should fail when the file does not
|
||||
* exist
|
||||
*
|
||||
* @throws NoSuchFileException
|
||||
* if the value of the {@code failIfNotExists} is {@code true} and
|
||||
* the file does not exist <i>(optional specific exception)</i>
|
||||
* @throws DirectoryNotEmptyException
|
||||
* if the file is a directory and could not otherwise be deleted
|
||||
* because the directory is not empty <i>(optional specific
|
||||
@ -454,7 +484,7 @@ public abstract class Path
|
||||
* installed, the {@link SecurityManager#checkDelete(String)} method
|
||||
* is invoked to check delete access to the file.
|
||||
*/
|
||||
public abstract void delete(boolean failIfNotExists) throws IOException;
|
||||
public abstract void deleteIfExists() throws IOException;
|
||||
|
||||
/**
|
||||
* Creates a symbolic link to a target <i>(optional operation)</i>.
|
||||
@ -536,8 +566,6 @@ public abstract class Path
|
||||
* or its {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method denies write access to both this path and the path of the
|
||||
* existing file.
|
||||
*
|
||||
* @see BasicFileAttributes#linkCount
|
||||
*/
|
||||
public abstract Path createLink(Path existing) throws IOException;
|
||||
|
||||
@ -608,7 +636,7 @@ public abstract class Path
|
||||
*
|
||||
* @return an absolute, hierarchical URI with a non-empty path component
|
||||
*
|
||||
* @throws IOError
|
||||
* @throws java.io.IOError
|
||||
* if an I/O error occurs obtaining the absolute path, or where a
|
||||
* file system is constructed to access the contents of a file as
|
||||
* a file system, and the URI of the enclosing file system cannot be
|
||||
@ -636,8 +664,9 @@ public abstract class Path
|
||||
* @throws IOError
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager
|
||||
* is installed, its {@link SecurityManager#checkPropertyAccess(String)
|
||||
* In the case of the default provider, a security manager
|
||||
* is installed, and this path is not absolute, then the security
|
||||
* manager's {@link SecurityManager#checkPropertyAccess(String)
|
||||
* checkPropertyAccess} method is invoked to check access to the
|
||||
* system property {@code user.dir}
|
||||
*/
|
||||
@ -720,7 +749,9 @@ public abstract class Path
|
||||
* the target file. The exact file attributes that are copied is platform
|
||||
* and file system dependent and therefore unspecified. Minimally, the
|
||||
* {@link BasicFileAttributes#lastModifiedTime last-modified-time} is
|
||||
* copied to the target file. </td>
|
||||
* copied to the target file if supported by both the source and target
|
||||
* file store. Copying of file timestamps may result in precision
|
||||
* loss. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} </td>
|
||||
@ -867,10 +898,7 @@ public abstract class Path
|
||||
*
|
||||
* <p> The directory stream's {@code close} method should be invoked after
|
||||
* iteration is completed so as to free any resources held for the open
|
||||
* directory. The {@link Files#withDirectory Files.withDirectory} utility
|
||||
* method is useful for cases where a task is performed on each accepted
|
||||
* entry in a directory. This method closes the directory when iteration is
|
||||
* complete (or an error occurs).
|
||||
* directory.
|
||||
*
|
||||
* <p> When an implementation supports operations on entries in the
|
||||
* directory that execute in a race-free manner then the returned directory
|
||||
@ -927,8 +955,6 @@ public abstract class Path
|
||||
*
|
||||
* @throws java.util.regex.PatternSyntaxException
|
||||
* if the pattern is invalid
|
||||
* @throws UnsupportedOperationException
|
||||
* if the pattern syntax is not known to the implementation
|
||||
* @throws NotDirectoryException
|
||||
* if the file could not otherwise be opened because it is not
|
||||
* a directory <i>(optional specific exception)</i>
|
||||
@ -950,19 +976,18 @@ public abstract class Path
|
||||
* directory. The {@code Path} objects are obtained as if by {@link
|
||||
* #resolve(Path) resolving} the name of the directory entry against this
|
||||
* path. The entries returned by the iterator are filtered by the given
|
||||
* {@link DirectoryStream.Filter filter}. The {@link DirectoryStreamFilters}
|
||||
* class defines factory methods that create useful filters.
|
||||
* {@link DirectoryStream.Filter filter}.
|
||||
*
|
||||
* <p> The directory stream's {@code close} method should be invoked after
|
||||
* iteration is completed so as to free any resources held for the open
|
||||
* directory. The {@link Files#withDirectory Files.withDirectory} utility
|
||||
* method is useful for cases where a task is performed on each accepted
|
||||
* entry in a directory. This method closes the directory when iteration is
|
||||
* complete (or an error occurs).
|
||||
* directory.
|
||||
*
|
||||
* <p> Where the filter terminates due to an uncaught error or runtime
|
||||
* exception then it propogated to the caller of the iterator's {@link
|
||||
* Iterator#hasNext() hasNext} or {@link Iterator#next() next} methods.
|
||||
* exception then it is propogated to the iterator's {@link Iterator#hasNext()
|
||||
* hasNext} or {@link Iterator#next() next} method. Where an {@code
|
||||
* IOException} is thrown, it is propogated as a {@link
|
||||
* java.util.concurrent.ConcurrentModificationException} with the {@code
|
||||
* IOException} as the cause.
|
||||
*
|
||||
* <p> When an implementation supports operations on entries in the
|
||||
* directory that execute in a race-free manner then the returned directory
|
||||
@ -973,14 +998,9 @@ public abstract class Path
|
||||
* larger than 8K.
|
||||
* <pre>
|
||||
* DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
|
||||
* public boolean accept(Path file) {
|
||||
* try {
|
||||
* long size = Attributes.readBasicFileAttributes(file).size();
|
||||
* return (size > 8192L);
|
||||
* } catch (IOException e) {
|
||||
* // failed to get size
|
||||
* return false;
|
||||
* }
|
||||
* public boolean accept(Path file) throws IOException {
|
||||
* long size = Attributes.readBasicFileAttributes(file).size();
|
||||
* return (size > 8192L);
|
||||
* }
|
||||
* };
|
||||
* Path dir = ...
|
||||
@ -1071,6 +1091,8 @@ public abstract class Path
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method is invoked to check write access to the new directory.
|
||||
*
|
||||
* @see Files#createDirectories
|
||||
*/
|
||||
public abstract Path createDirectory(FileAttribute<?>... attrs)
|
||||
throws IOException;
|
||||
@ -1159,7 +1181,7 @@ public abstract class Path
|
||||
* FileAttribute file-attributes} to set atomically when a new file is created.
|
||||
*
|
||||
* <p> In the case of the default provider, the returned seekable byte channel
|
||||
* is a {@link FileChannel}.
|
||||
* is a {@link java.nio.channels.FileChannel}.
|
||||
*
|
||||
* <p> <b>Usage Examples:</b>
|
||||
* <pre>
|
||||
@ -1212,12 +1234,9 @@ public abstract class Path
|
||||
* Opens or creates a file, returning a seekable byte channel to access the
|
||||
* file.
|
||||
*
|
||||
* <p> This method extends the options defined by the {@code FileRef}
|
||||
* interface and to the options specified by the {@link
|
||||
* #newByteChannel(Set,FileAttribute[]) newByteChannel} method
|
||||
* except that the options are specified by an array. In the case of the
|
||||
* default provider, the returned seekable byte channel is a {@link
|
||||
* FileChannel}.
|
||||
* <p> This method opens or creates a file in exactly the manner specified
|
||||
* by the {@link Path#newByteChannel(Set,FileAttribute[]) newByteChannel}
|
||||
* method.
|
||||
*
|
||||
* @param options
|
||||
* options specifying how the file is opened
|
||||
@ -1232,108 +1251,40 @@ public abstract class Path
|
||||
* if a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public abstract SeekableByteChannel newByteChannel(OpenOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Opens the file located by this path for reading, returning an input
|
||||
* stream to read bytes from the file. The stream will not be buffered, and
|
||||
* is not required to support the {@link InputStream#mark mark} or {@link
|
||||
* InputStream#reset reset} methods. The stream will be safe for access by
|
||||
* multiple concurrent threads. Reading commences at the beginning of the file.
|
||||
*
|
||||
* @return an input stream to read bytes from the file
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the file.
|
||||
* method is invoked to check read access to the path if the file is
|
||||
* opened for reading. The {@link SecurityManager#checkWrite(String)
|
||||
* checkWrite} method is invoked to check write access to the path
|
||||
* if the file is opened for writing.
|
||||
*/
|
||||
public abstract InputStream newInputStream() throws IOException;
|
||||
public abstract SeekableByteChannel newByteChannel(OpenOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Opens or creates the file located by this path for writing, returning an
|
||||
* output stream to write bytes to the file.
|
||||
* Opens or creates the file located by this object for writing, returning
|
||||
* an output stream to write bytes to the file.
|
||||
*
|
||||
* <p> This method opens or creates a file in exactly the manner specified
|
||||
* by the {@link Path#newByteChannel(Set,FileAttribute[]) newByteChannel}
|
||||
* method except that the {@link StandardOpenOption#READ READ} option may not
|
||||
* be present in the array of open options. If no open options are present
|
||||
* then this method creates a new file for writing or truncates an existing
|
||||
* file.
|
||||
*
|
||||
* <p> The resulting stream will not be buffered. The stream will be safe
|
||||
* for access by multiple concurrent threads.
|
||||
*
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we wish to open a log file for writing so that we append to the
|
||||
* file if it already exists, or create it when it doesn't exist.
|
||||
* <pre>
|
||||
* Path logfile = ...
|
||||
* OutputStream out = new BufferedOutputStream(logfile.newOutputStream(CREATE, APPEND));
|
||||
* </pre>
|
||||
* be present in the array of open options.
|
||||
*
|
||||
* @param options
|
||||
* options specifying how the file is opened
|
||||
*
|
||||
* @return a new seekable byte channel
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if {@code options} contains an invalid combination of options
|
||||
* @throws UnsupportedOperationException
|
||||
* if an unsupported open option is specified
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method is invoked to check write access to the file.
|
||||
*/
|
||||
public abstract OutputStream newOutputStream(OpenOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Opens or creates the file located by this path for writing, returning an
|
||||
* output stream to write bytes to the file.
|
||||
*
|
||||
* <p> This method opens or creates a file in exactly the manner specified
|
||||
* by the {@link Path#newByteChannel(Set,FileAttribute[]) newByteChannel}
|
||||
* method except that {@code options} parameter may not contain the {@link
|
||||
* StandardOpenOption#READ READ} option. If no open options are present
|
||||
* then this method creates a new file for writing or truncates an existing
|
||||
* file.
|
||||
*
|
||||
* <p> The resulting stream will not be buffered. The stream will be safe
|
||||
* for access by multiple concurrent threads.
|
||||
*
|
||||
* @param options
|
||||
* options specifying how the file is opened
|
||||
* @param attrs
|
||||
* an optional list of file attributes to set atomically when
|
||||
* creating the file
|
||||
*
|
||||
* @return a new output stream
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the set contains an invalid combination of options
|
||||
* @throws UnsupportedOperationException
|
||||
* if an unsupported open option is specified or the array contains
|
||||
* attributes that cannot be set atomically when creating the file
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method is invoked to check write access to the file.
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws UnsupportedOperationException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
public abstract OutputStream newOutputStream(Set<? extends OpenOption> options,
|
||||
FileAttribute<?>... attrs)
|
||||
@Override
|
||||
public abstract OutputStream newOutputStream(OpenOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
@ -1358,6 +1309,80 @@ public abstract class Path
|
||||
*/
|
||||
public abstract boolean isHidden() throws IOException;
|
||||
|
||||
/**
|
||||
* Checks the existence and optionally the accessibility of the file
|
||||
* located by this path.
|
||||
*
|
||||
* <p> This method checks the existence of a file and that this Java virtual
|
||||
* machine has appropriate privileges that would allow it access the file
|
||||
* according to all of access modes specified in the {@code modes} parameter
|
||||
* as follows:
|
||||
*
|
||||
* <table border=1 cellpadding=5 summary="">
|
||||
* <tr> <th>Value</th> <th>Description</th> </tr>
|
||||
* <tr>
|
||||
* <td> {@link AccessMode#READ READ} </td>
|
||||
* <td> Checks that the file exists and that the Java virtual machine has
|
||||
* permission to read the file. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link AccessMode#WRITE WRITE} </td>
|
||||
* <td> Checks that the file exists and that the Java virtual machine has
|
||||
* permission to write to the file, </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@link AccessMode#EXECUTE EXECUTE} </td>
|
||||
* <td> Checks that the file exists and that the Java virtual machine has
|
||||
* permission to {@link Runtime#exec execute} the file. The semantics
|
||||
* may differ when checking access to a directory. For example, on UNIX
|
||||
* systems, checking for {@code EXECUTE} access checks that the Java
|
||||
* virtual machine has permission to search the directory in order to
|
||||
* access file or subdirectories. </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p> If the {@code modes} parameter is of length zero, then the existence
|
||||
* of the file is checked.
|
||||
*
|
||||
* <p> This method follows symbolic links if the file referenced by this
|
||||
* object is a symbolic link. Depending on the implementation, this method
|
||||
* may require to read file permissions, access control lists, or other
|
||||
* file attributes in order to check the effective access to the file. To
|
||||
* determine the effective access to a file may require access to several
|
||||
* attributes and so in some implementations this method may not be atomic
|
||||
* with respect to other file system operations. Furthermore, as the result
|
||||
* of this method is immediately outdated, there is no guarantee that a
|
||||
* subsequence access will succeed (or even that it will access the same
|
||||
* file). Care should be taken when using this method in security sensitive
|
||||
* applications.
|
||||
*
|
||||
* @param modes
|
||||
* The access modes to check; may have zero elements
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* an implementation is required to support checking for
|
||||
* {@code READ}, {@code WRITE}, and {@code EXECUTE} access. This
|
||||
* exception is specified to allow for the {@code Access} enum to
|
||||
* be extended in future releases.
|
||||
* @throws NoSuchFileException
|
||||
* if a file does not exist <i>(optional specific exception)</i>
|
||||
* @throws AccessDeniedException
|
||||
* the requested access would be denied or the access cannot be
|
||||
* determined because the Java virtual machine has insufficient
|
||||
* privileges or other reasons. <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* is invoked when checking read access to the file or only the
|
||||
* existence of the file, the {@link SecurityManager#checkWrite(String)
|
||||
* checkWrite} is invoked when checking write access to the file,
|
||||
* and {@link SecurityManager#checkExec(String) checkExec} is invoked
|
||||
* when checking execute access.
|
||||
*/
|
||||
public abstract void checkAccess(AccessMode... modes) throws IOException;
|
||||
|
||||
/**
|
||||
* Tests whether the file located by this path exists.
|
||||
*
|
||||
@ -1414,6 +1439,30 @@ public abstract class Path
|
||||
*/
|
||||
public abstract boolean notExists();
|
||||
|
||||
/**
|
||||
* Returns the {@link FileStore} representing the file store where an
|
||||
* existing file, located by this path, is stored.
|
||||
*
|
||||
* <p> Once a reference to the {@code FileStore} is obtained it is
|
||||
* implementation specific if operations on the returned {@code FileStore},
|
||||
* or {@link FileStoreAttributeView} objects obtained from it, continue
|
||||
* to depend on the existence of the file. In particular the behavior is not
|
||||
* defined for the case that the file is deleted or moved to a different
|
||||
* file store.
|
||||
*
|
||||
* @return the file store where the file is stored
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the file, and in
|
||||
* addition it checks {@link RuntimePermission}<tt>
|
||||
* ("getFileStoreAttributes")</tt>
|
||||
*/
|
||||
public abstract FileStore getFileStore() throws IOException;
|
||||
|
||||
// -- watchable --
|
||||
|
||||
/**
|
||||
@ -1561,6 +1610,49 @@ public abstract class Path
|
||||
@Override
|
||||
public abstract int compareTo(Path other);
|
||||
|
||||
/**
|
||||
* Tests if the file referenced by this object is the same file referenced
|
||||
* by another object.
|
||||
*
|
||||
* <p> If this {@code FileRef} and the given {@code FileRef} are {@link
|
||||
* #equals(Object) equal} then this method returns {@code true} without checking
|
||||
* if the file exists. If the {@code FileRef} and the given {@code FileRef}
|
||||
* are associated with different providers, or the given {@code FileRef} is
|
||||
* {@code null} then this method returns {@code false}. Otherwise, this method
|
||||
* checks if both {@code FileRefs} locate the same file, and depending on the
|
||||
* implementation, may require to open or access both files.
|
||||
*
|
||||
* <p> If the file system and files remain static, then this method implements
|
||||
* an equivalence relation for non-null {@code FileRefs}.
|
||||
* <ul>
|
||||
* <li>It is <i>reflexive</i>: for a non-null {@code FileRef} {@code f},
|
||||
* {@code f.isSameFile(f)} should return {@code true}.
|
||||
* <li>It is <i>symmetric</i>: for two non-null {@code FileRefs}
|
||||
* {@code f} and {@code g}, {@code f.isSameFile(g)} will equal
|
||||
* {@code g.isSameFile(f)}.
|
||||
* <li>It is <i>transitive</i>: for three {@code FileRefs}
|
||||
* {@code f}, {@code g}, and {@code h}, if {@code f.isSameFile(g)} returns
|
||||
* {@code true} and {@code g.isSameFile(h)} returns {@code true}, then
|
||||
* {@code f.isSameFile(h)} will return return {@code true}.
|
||||
* </ul>
|
||||
*
|
||||
* @param other
|
||||
* the other file reference
|
||||
*
|
||||
* @return {@code true} if, and only if, this object and the given object
|
||||
* locate the same file
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to both files.
|
||||
*
|
||||
* @see java.nio.file.attribute.BasicFileAttributes#fileKey
|
||||
*/
|
||||
public abstract boolean isSameFile(Path other) throws IOException;
|
||||
|
||||
/**
|
||||
* Tests this path for equality with the given object.
|
||||
*
|
||||
|
||||
@ -35,7 +35,7 @@ import java.net.URI;
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public class Paths {
|
||||
public final class Paths {
|
||||
private Paths() { }
|
||||
|
||||
/**
|
||||
@ -106,8 +106,9 @@ public class Paths {
|
||||
* if preconditions on the {@code uri} parameter do not hold. The
|
||||
* format of the URI is provider specific.
|
||||
* @throws FileSystemNotFoundException
|
||||
* if the file system identified by the URI does not exist or the
|
||||
* provider identified by the URI's scheme component is not installed
|
||||
* The file system, identified by the URI, does not exist and
|
||||
* cannot be created automatically, or the provider identified by
|
||||
* the URI's scheme component is not installed
|
||||
* @throws SecurityException
|
||||
* if a security manager is installed and it denies an unspecified
|
||||
* permission to access the file system
|
||||
|
||||
@ -36,7 +36,7 @@ import java.io.IOException;
|
||||
* traverse file trees or otherwise operate on directories in a race-free manner.
|
||||
* Race conditions can arise when a sequence of file operations cannot be
|
||||
* carried out in isolation. Each of the file operations defined by this
|
||||
* interface specify a relative {@link Path}. All access to the file is relative
|
||||
* interface specify a relative path. All access to the file is relative
|
||||
* to the open directory irrespective of if the directory is moved or replaced
|
||||
* by an attacker while the directory is open. A {@code SecureDirectoryStream}
|
||||
* may also be used as a virtual <em>working directory</em>.
|
||||
@ -65,8 +65,8 @@ import java.io.IOException;
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public abstract class SecureDirectoryStream
|
||||
implements DirectoryStream<Path>
|
||||
public abstract class SecureDirectoryStream<T>
|
||||
implements DirectoryStream<T>
|
||||
{
|
||||
/**
|
||||
* Initialize a new instance of this class.
|
||||
@ -78,13 +78,12 @@ public abstract class SecureDirectoryStream
|
||||
* SecureDirectoryStream} to iterate over the entries in the directory.
|
||||
*
|
||||
* <p> This method works in exactly the manner specified by the {@link
|
||||
* Path#newDirectoryStream newDirectoryStream} method for the case that
|
||||
* Path#newDirectoryStream() newDirectoryStream} method for the case that
|
||||
* the {@code path} parameter is an {@link Path#isAbsolute absolute} path.
|
||||
* When the parameter is a relative path then the directory to open is
|
||||
* relative to this open directory. The {@code followLinks} parameter
|
||||
* determines if links should be followed. If this parameter is {@code
|
||||
* false} and the file is a symbolic link then this method fails (by
|
||||
* throwing an I/O exception).
|
||||
* relative to this open directory. The {@link
|
||||
* LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} option may be used to
|
||||
* ensure that this method fails if the file is a symbolic link.
|
||||
*
|
||||
* <p> The new directory stream, once created, is not dependent upon the
|
||||
* directory stream used to create it. Closing this directory stream has no
|
||||
@ -92,10 +91,8 @@ public abstract class SecureDirectoryStream
|
||||
*
|
||||
* @param path
|
||||
* the path to the directory to open
|
||||
* @param followLinks
|
||||
* {@code true} if the links should be followed
|
||||
* @param filter
|
||||
* the directory stream filter or {@code null}.
|
||||
* @param options
|
||||
* options indicating how symbolic links are handled
|
||||
*
|
||||
* @return a new and open {@code SecureDirectoryStream} object
|
||||
*
|
||||
@ -111,9 +108,8 @@ public abstract class SecureDirectoryStream
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the directory.
|
||||
*/
|
||||
public abstract SecureDirectoryStream newDirectoryStream(Path path,
|
||||
boolean followLinks,
|
||||
DirectoryStream.Filter<? super Path> filter)
|
||||
public abstract SecureDirectoryStream<T> newDirectoryStream(T path,
|
||||
LinkOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
@ -162,7 +158,7 @@ public abstract class SecureDirectoryStream
|
||||
* checkWrite} method is invoked to check write access to the path
|
||||
* if the file is opened for writing.
|
||||
*/
|
||||
public abstract SeekableByteChannel newByteChannel(Path path,
|
||||
public abstract SeekableByteChannel newByteChannel(T path,
|
||||
Set<? extends OpenOption> options,
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException;
|
||||
@ -170,7 +166,7 @@ public abstract class SecureDirectoryStream
|
||||
/**
|
||||
* Deletes a file.
|
||||
*
|
||||
* <p> Unlike the {@link FileRef#delete delete()} method, this method
|
||||
* <p> Unlike the {@link Path#delete delete()} method, this method
|
||||
* does not first examine the file to determine if the file is a directory.
|
||||
* Whether a directory is deleted by this method is system dependent and
|
||||
* therefore not specified. If the file is a symbolic-link then the link is
|
||||
@ -191,12 +187,12 @@ public abstract class SecureDirectoryStream
|
||||
* installed, the {@link SecurityManager#checkDelete(String) checkDelete}
|
||||
* method is invoked to check delete access to the file
|
||||
*/
|
||||
public abstract void deleteFile(Path path) throws IOException;
|
||||
public abstract void deleteFile(T path) throws IOException;
|
||||
|
||||
/**
|
||||
* Deletes a directory.
|
||||
*
|
||||
* <p> Unlike the {@link FileRef#delete delete()} method, this method
|
||||
* <p> Unlike the {@link Path#delete delete()} method, this method
|
||||
* does not first examine the file to determine if the file is a directory.
|
||||
* Whether non-directories are deleted by this method is system dependent and
|
||||
* therefore not specified. When the parameter is a relative path then the
|
||||
@ -219,7 +215,7 @@ public abstract class SecureDirectoryStream
|
||||
* installed, the {@link SecurityManager#checkDelete(String) checkDelete}
|
||||
* method is invoked to check delete access to the directory
|
||||
*/
|
||||
public abstract void deleteDirectory(Path path) throws IOException;
|
||||
public abstract void deleteDirectory(T path) throws IOException;
|
||||
|
||||
/**
|
||||
* Move a file from this directory to another directory.
|
||||
@ -259,7 +255,7 @@ public abstract class SecureDirectoryStream
|
||||
* method is invoked to check write access to both the source and
|
||||
* target file.
|
||||
*/
|
||||
public abstract void move(Path srcpath, SecureDirectoryStream targetdir, Path targetpath)
|
||||
public abstract void move(T srcpath, SecureDirectoryStream<T> targetdir, T targetpath)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
@ -318,7 +314,7 @@ public abstract class SecureDirectoryStream
|
||||
* type is not available
|
||||
*
|
||||
*/
|
||||
public abstract <V extends FileAttributeView> V getFileAttributeView(Path path,
|
||||
public abstract <V extends FileAttributeView> V getFileAttributeView(T path,
|
||||
Class<V> type,
|
||||
LinkOption... options);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ import java.io.IOError;
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public class SimpleFileVisitor<T extends FileRef> implements FileVisitor<T> {
|
||||
public class SimpleFileVisitor<T> implements FileVisitor<T> {
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
*/
|
||||
|
||||
@ -31,7 +31,7 @@ package java.nio.file;
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public class StandardWatchEventKind {
|
||||
public final class StandardWatchEventKind {
|
||||
private StandardWatchEventKind() { }
|
||||
|
||||
/**
|
||||
|
||||
@ -103,7 +103,7 @@ public abstract class WatchKey {
|
||||
*
|
||||
* <p> Note that this method does not wait if there are no events pending.
|
||||
*
|
||||
* @return the list of the events retrieved
|
||||
* @return the list of the events retrieved; may be empty
|
||||
*/
|
||||
public abstract List<WatchEvent<?>> pollEvents();
|
||||
|
||||
@ -128,7 +128,7 @@ public abstract class WatchKey {
|
||||
* will be invalid. If the watch key is enqueued, waiting to be retrieved
|
||||
* from the watch service, then it will remain in the queue until it is
|
||||
* removed. Pending events, if any, remain pending and may be retrieved by
|
||||
* invoking the {@link #pollEvents pollEvents} method event after the key is
|
||||
* invoking the {@link #pollEvents pollEvents} method after the key is
|
||||
* cancelled.
|
||||
*
|
||||
* <p> If this watch key has already been cancelled then invoking this
|
||||
|
||||
@ -110,13 +110,13 @@ import java.io.IOException;
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> The {@link #getAttribute getAttribute} or {@link #readAttributes
|
||||
* readAttributes} methods may be used to read the ACL or owner attributes as if
|
||||
* by invoking the {@link #getAcl getAcl} or {@link #getOwner getOwner} methods.
|
||||
* <p> The {@link FileRef#getAttribute getAttribute} method may be used to read
|
||||
* the ACL or owner attributes as if by invoking the {@link #getAcl getAcl} or
|
||||
* {@link #getOwner getOwner} methods.
|
||||
*
|
||||
* <p> The {@link #setAttribute setAttribute} method may be used to update the
|
||||
* ACL or owner attributes as if by invoking the {@link #setAcl setAcl} or {@link
|
||||
* #setOwner setOwner} methods.
|
||||
* <p> The {@link FileRef#setAttribute setAttribute} method may be used to
|
||||
* update the ACL or owner attributes as if by invoking the {@link #setAcl setAcl}
|
||||
* or {@link #setOwner setOwner} methods.
|
||||
*
|
||||
* <h4> Setting the ACL when creating a file </h4>
|
||||
*
|
||||
|
||||
@ -25,20 +25,12 @@
|
||||
|
||||
package java.nio.file.attribute;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* An object that provides a read-only or updatable <em>view</em> of non-opaque
|
||||
* values associated with an object in a filesystem. This interface is extended
|
||||
* or implemented by specific attribute views that define the attributes
|
||||
* supported by the view. A specific attribute view will typically define
|
||||
* type-safe methods to read or update the attributes that it supports. It also
|
||||
* provides <em>dynamic access</em> where the {@link #readAttributes
|
||||
* readAttributes}, {@link #getAttribute getAttribute} and {@link #setAttribute
|
||||
* setAttributs} methods are used to access the attributes by names defined
|
||||
* by the attribute view. Implementations must ensure that the attribute names
|
||||
* do not contain the colon (':') or comma (',') characters.
|
||||
* type-safe methods to read or update the attributes that it supports.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
@ -48,71 +40,4 @@ public interface AttributeView {
|
||||
* Returns the name of the attribute view.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Reads the value of an attribute.
|
||||
*
|
||||
* @param attribute
|
||||
* the attribute name (case sensitive)
|
||||
*
|
||||
* @return the value of the attribute, or {@code null} if the attribute is
|
||||
* not supported
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* if a security manager is set and it denies access
|
||||
*/
|
||||
Object getAttribute(String attribute) throws IOException;
|
||||
|
||||
/**
|
||||
* Sets/updates the value of an attribute.
|
||||
*
|
||||
* @param attribute
|
||||
* the attribute name (case sensitive)
|
||||
* @param value
|
||||
* the attribute value
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* if the attribute is not supported or this attribute view does
|
||||
* not support updating the value of the attribute
|
||||
* @throws IllegalArgumentException
|
||||
* if the attribute value is of the correct type but has an
|
||||
* inappropriate value
|
||||
* @throws ClassCastException
|
||||
* if the attribute value is not of the expected type or is a
|
||||
* collection containing elements that are not of the expected
|
||||
* type
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* if a security manager is set and it denies access
|
||||
*/
|
||||
void setAttribute(String attribute, Object value) throws IOException;
|
||||
|
||||
/**
|
||||
* Reads all, or a subset, of the attributes supported by this file attribute
|
||||
* view.
|
||||
*
|
||||
* <p> The {@code first} and {@code rest} parameters are the names of the
|
||||
* attributes to read. If any of the parameters has the value {@code "*"}
|
||||
* then all attributes are read. Attributes that are not supported are
|
||||
* ignored and will not be present in the returned map. It is implementation
|
||||
* specific if all attributes are read as an atomic operation with respect
|
||||
* to other file system operations.
|
||||
*
|
||||
* @param first
|
||||
* the name of an attribute to read (case sensitive)
|
||||
* @param rest
|
||||
* the names of other attributes to read (case sensitive)
|
||||
*
|
||||
* @return an unmodifiable map of the attributes; may be empty. Its keys are
|
||||
* the attribute names, its values are the attribute values
|
||||
*
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* if a security manager is set and it denies access
|
||||
*/
|
||||
Map<String,?> readAttributes(String first, String... rest) throws IOException;
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@ package java.nio.file.attribute;
|
||||
import java.nio.file.*;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* This class consists exclusively of static methods that operate on or return
|
||||
@ -39,245 +38,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
|
||||
public final class Attributes {
|
||||
private Attributes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the given attribute name into the name of an attribute view and
|
||||
* the attribute. If the attribute view is not identified then it assumed
|
||||
* to be "basic".
|
||||
*/
|
||||
private static String[] split(String attribute) {
|
||||
String[] s = new String[2];
|
||||
int pos = attribute.indexOf(':');
|
||||
if (pos == -1) {
|
||||
s[0] = "basic";
|
||||
s[1] = attribute;
|
||||
} else {
|
||||
s[0] = attribute.substring(0, pos++);
|
||||
s[1] = (pos == attribute.length()) ? "" : attribute.substring(pos);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of a file attribute.
|
||||
*
|
||||
* <p> The {@code attribute} parameter identifies the attribute to be set
|
||||
* and takes the form:
|
||||
* <blockquote>
|
||||
* [<i>view-name</i><b>:</b>]<i>attribute-name</i>
|
||||
* </blockquote>
|
||||
* where square brackets [...] delineate an optional component and the
|
||||
* character {@code ':'} stands for itself.
|
||||
*
|
||||
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
|
||||
* FileAttributeView} that identifies a set of file attributes. If not
|
||||
* specified then it defaults to {@code "basic"}, the name of the file
|
||||
* attribute view that identifies the basic set of file attributes common to
|
||||
* many file systems. <i>attribute-name</i> is the name of the attribute
|
||||
* within the set.
|
||||
*
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we want to set the DOS "hidden" attribute:
|
||||
* <pre>
|
||||
* Attributes.setAttribute(file, "dos:hidden", true);
|
||||
* </pre>
|
||||
*
|
||||
* @param file
|
||||
* A file reference that locates the file
|
||||
* @param attribute
|
||||
* The attribute to set
|
||||
* @param value
|
||||
* The attribute value
|
||||
*
|
||||
* @throws UnsupportedOperationException
|
||||
* If the attribute view is not available or it does not
|
||||
* support updating the attribute
|
||||
* @throws IllegalArgumentException
|
||||
* If the attribute value is of the correct type but has an
|
||||
* inappropriate value
|
||||
* @throws ClassCastException
|
||||
* If the attribute value is not of the expected type or is a
|
||||
* collection containing elements that are not of the expected
|
||||
* type
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, its {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method denies write access to the file. If this method is invoked
|
||||
* to set security sensitive attributes then the security manager
|
||||
* may be invoked to check for additional permissions.
|
||||
*/
|
||||
public static void setAttribute(FileRef file, String attribute, Object value)
|
||||
throws IOException
|
||||
{
|
||||
String[] s = split(attribute);
|
||||
FileAttributeView view = file.getFileAttributeView(s[0]);
|
||||
if (view == null)
|
||||
throw new UnsupportedOperationException("View '" + s[0] + "' not available");
|
||||
view.setAttribute(s[1], value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the value of a file attribute.
|
||||
*
|
||||
* <p> The {@code attribute} parameter identifies the attribute to be read
|
||||
* and takes the form:
|
||||
* <blockquote>
|
||||
* [<i>view-name</i><b>:</b>]<i>attribute-name</i>
|
||||
* </blockquote>
|
||||
* where square brackets [...] delineate an optional component and the
|
||||
* character {@code ':'} stands for itself.
|
||||
*
|
||||
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
|
||||
* FileAttributeView} that identifies a set of file attributes. If not
|
||||
* specified then it defaults to {@code "basic"}, the name of the file
|
||||
* attribute view that identifies the basic set of file attributes common to
|
||||
* many file systems. <i>attribute-name</i> is the name of the attribute.
|
||||
*
|
||||
* <p> The {@code options} array may be used to indicate how symbolic links
|
||||
* are handled for the case that the file is a symbolic link. By default,
|
||||
* symbolic links are followed and the file attribute of the final target
|
||||
* of the link is read. If the option {@link LinkOption#NOFOLLOW_LINKS
|
||||
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
|
||||
* the method returns the file attribute of the symbolic link.
|
||||
*
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we require the user ID of the file owner on a system that
|
||||
* supports a "{@code unix}" view:
|
||||
* <pre>
|
||||
* int uid = (Integer)Attributes.getAttribute(file, "unix:uid");
|
||||
* </pre>
|
||||
*
|
||||
* @param file
|
||||
* A file reference that locates the file
|
||||
* @param attribute
|
||||
* The attribute to read
|
||||
* @param options
|
||||
* Options indicating how symbolic links are handled
|
||||
*
|
||||
* @return The attribute value, or {@code null} if the attribute view
|
||||
* is not available or it does not support reading the attribute
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, its {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method denies read access to the file. If this method is invoked
|
||||
* to read security sensitive attributes then the security manager
|
||||
* may be invoked to check for additional permissions.
|
||||
*/
|
||||
public static Object getAttribute(FileRef file,
|
||||
String attribute,
|
||||
LinkOption... options)
|
||||
throws IOException
|
||||
{
|
||||
String[] s = split(attribute);
|
||||
FileAttributeView view = file.getFileAttributeView(s[0], options);
|
||||
if (view != null)
|
||||
return view.getAttribute(s[1]);
|
||||
// view not available
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a set of file attributes as a bulk operation.
|
||||
*
|
||||
* <p> The {@code attributes} parameter identifies the attributes to be read
|
||||
* and takes the form:
|
||||
* <blockquote>
|
||||
* [<i>view-name</i><b>:</b>]<i>attribute-list</i>
|
||||
* </blockquote>
|
||||
* where square brackets [...] delineate an optional component and the
|
||||
* character {@code ':'} stands for itself.
|
||||
*
|
||||
* <p> <i>view-name</i> is the {@link FileAttributeView#name name} of a {@link
|
||||
* FileAttributeView} that identifies a set of file attributes. If not
|
||||
* specified then it defaults to {@code "basic"}, the name of the file
|
||||
* attribute view that identifies the basic set of file attributes common to
|
||||
* many file systems.
|
||||
*
|
||||
* <p> The <i>attribute-list</i> component is a comma separated list of
|
||||
* zero or more names of attributes to read. If the list contains the value
|
||||
* {@code "*"} then all attributes are read. Attributes that are not supported
|
||||
* are ignored and will not be present in the returned map. It is
|
||||
* implementation specific if all attributes are read as an atomic operation
|
||||
* with respect to other file system operations.
|
||||
*
|
||||
* <p> The following examples demonstrate possible values for the {@code
|
||||
* attributes} parameter:
|
||||
*
|
||||
* <blockquote>
|
||||
* <table border="0">
|
||||
* <tr>
|
||||
* <td> {@code "*"} </td>
|
||||
* <td> Read all {@link BasicFileAttributes basic-file-attributes}. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code "size,lastModifiedTime,lastAccessTime"} </td>
|
||||
* <td> Reads the file size, last modified time, and last access time
|
||||
* attributes. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code "posix:*"} </td>
|
||||
* <td> Read all {@link PosixFileAttributes POSIX-file-attributes}.. </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> {@code "posix:permissions,owner,size"} </td>
|
||||
* <td> Reads the POSX file permissions, owner, and file size. </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> The {@code options} array may be used to indicate how symbolic links
|
||||
* are handled for the case that the file is a symbolic link. By default,
|
||||
* symbolic links are followed and the file attributes of the final target
|
||||
* of the link are read. If the option {@link LinkOption#NOFOLLOW_LINKS
|
||||
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
|
||||
* the method returns the file attributes of the symbolic link.
|
||||
*
|
||||
* @param file
|
||||
* A file reference that locates the file
|
||||
* @param attributes
|
||||
* The attributes to read
|
||||
* @param options
|
||||
* Options indicating how symbolic links are handled
|
||||
*
|
||||
* @return A map of the attributes returned; may be empty. The map's keys
|
||||
* are the attribute names, its values are the attribute values
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, its {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method denies read access to the file. If this method is invoked
|
||||
* to read security sensitive attributes then the security manager
|
||||
* may be invoke to check for additional permissions.
|
||||
*/
|
||||
public static Map<String,?> readAttributes(FileRef file,
|
||||
String attributes,
|
||||
LinkOption... options)
|
||||
throws IOException
|
||||
{
|
||||
String[] s = split(attributes);
|
||||
FileAttributeView view = file.getFileAttributeView(s[0], options);
|
||||
if (view != null) {
|
||||
// further split attributes into the first and rest.
|
||||
String[] names = s[1].split(",");
|
||||
int rem = names.length-1;
|
||||
String first = names[0];
|
||||
String[] rest = new String[rem];
|
||||
if (rem > 0) System.arraycopy(names, 1, rest, 0, rem);
|
||||
|
||||
return view.readAttributes(first, rest);
|
||||
}
|
||||
// view not available
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
private Attributes() { }
|
||||
|
||||
/**
|
||||
* Reads the basic file attributes of a file.
|
||||
@ -551,29 +312,28 @@ public final class Attributes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the value of a file's last modified time attribute.
|
||||
* Updates a file's last modified time attribute. The file time is converted
|
||||
* to the epoch and precision supported by the file system. Converting from
|
||||
* finer to coarser granularities result in precision loss. The behavior of
|
||||
* this method when attempting to set a timestamp to a value that is outside
|
||||
* the range supported by the underlying file store is not defined. It may
|
||||
* or not fail by throwing an {@code IOException}.
|
||||
*
|
||||
* <p> The time value is measured since the epoch
|
||||
* (00:00:00 GMT, January 1, 1970) and is converted to the precision supported
|
||||
* by the file system. Converting from finer to coarser granularities result
|
||||
* in precision loss.
|
||||
* <p> If the file system does not support a last modified time attribute
|
||||
* then this method has no effect.
|
||||
*
|
||||
* <p> If the file system does not support a last modified time attribute then
|
||||
* this method has no effect.
|
||||
* <p> <b>Usage Example:</b>
|
||||
* Suppose we want to set the last modified time to the current time:
|
||||
* <pre>
|
||||
* FileTime now = FileTime.fromMillis(System.currentTimeMillis());
|
||||
* Attributes.setLastModifiedTime(file, now);
|
||||
* </pre>
|
||||
*
|
||||
* @param file
|
||||
* A file reference that locates the file
|
||||
*
|
||||
* @param lastModifiedTime
|
||||
* The new last modified time, or {@code -1L} to update it to
|
||||
* the current time
|
||||
* @param unit
|
||||
* A {@code TimeUnit} determining how to interpret the
|
||||
* {@code lastModifiedTime} parameter
|
||||
* The new last modified time
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the {@code lastModifiedime} parameter is a negative value other
|
||||
* than {@code -1L}
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
@ -584,35 +344,31 @@ public final class Attributes {
|
||||
* @see BasicFileAttributeView#setTimes
|
||||
*/
|
||||
public static void setLastModifiedTime(FileRef file,
|
||||
long lastModifiedTime,
|
||||
TimeUnit unit)
|
||||
FileTime lastModifiedTime)
|
||||
throws IOException
|
||||
{
|
||||
if (lastModifiedTime == null)
|
||||
throw new NullPointerException("'lastModifiedTime' is null");
|
||||
file.getFileAttributeView(BasicFileAttributeView.class)
|
||||
.setTimes(lastModifiedTime, null, null, unit);
|
||||
.setTimes(lastModifiedTime, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the value of a file's last access time attribute.
|
||||
*
|
||||
* <p> The time value is measured since the epoch
|
||||
* (00:00:00 GMT, January 1, 1970) and is converted to the precision supported
|
||||
* by the file system. Converting from finer to coarser granularities result
|
||||
* in precision loss.
|
||||
* Updates a file's last access time attribute. The file time is converted
|
||||
* to the epoch and precision supported by the file system. Converting from
|
||||
* finer to coarser granularities result in precision loss. The behavior of
|
||||
* this method when attempting to set a timestamp to a value that is outside
|
||||
* the range supported by the underlying file store is not defined. It may
|
||||
* or not fail by throwing an {@code IOException}.
|
||||
*
|
||||
* <p> If the file system does not support a last access time attribute then
|
||||
* this method has no effect.
|
||||
*
|
||||
* @param file
|
||||
* A file reference that locates the file
|
||||
* @param lastAccessTime
|
||||
* The new last access time, or {@code -1L} to update it to
|
||||
* the current time
|
||||
* @param unit
|
||||
* A {@code TimeUnit} determining how to interpret the
|
||||
* {@code lastModifiedTime} parameter
|
||||
* The new last access time
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the {@code lastAccessTime} parameter is a negative value other
|
||||
* than {@code -1L}
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
@ -623,12 +379,13 @@ public final class Attributes {
|
||||
* @see BasicFileAttributeView#setTimes
|
||||
*/
|
||||
public static void setLastAccessTime(FileRef file,
|
||||
long lastAccessTime,
|
||||
TimeUnit unit)
|
||||
FileTime lastAccessTime)
|
||||
throws IOException
|
||||
{
|
||||
if (lastAccessTime == null)
|
||||
throw new NullPointerException("'lastAccessTime' is null");
|
||||
file.getFileAttributeView(BasicFileAttributeView.class)
|
||||
.setTimes(null, lastAccessTime, null, unit);
|
||||
.setTimes(null, lastAccessTime, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package java.nio.file.attribute;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@ -49,19 +48,15 @@ import java.io.IOException;
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> "lastModifiedTime" </td>
|
||||
* <td> {@link Long} </td>
|
||||
* <td> {@link FileTime} </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> "lastAccessTime" </td>
|
||||
* <td> {@link Long} </td>
|
||||
* <td> {@link FileTime} </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> "creationTime" </td>
|
||||
* <td> {@link Long} </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> "resolution" </td>
|
||||
* <td> {@link java.util.concurrent.TimeUnit} </td>
|
||||
* <td> {@link FileTime} </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> "size" </td>
|
||||
@ -84,26 +79,19 @@ import java.io.IOException;
|
||||
* <td> {@link Boolean} </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> "linkCount" </td>
|
||||
* <td> {@link Integer} </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td> "fileKey" </td>
|
||||
* <td> {@link Object} </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> The {@link #getAttribute getAttribute} or {@link
|
||||
* #readAttributes(String,String[]) readAttributes(String,String[])} methods may
|
||||
* be used to read any of these attributes as if by invoking the {@link
|
||||
* <p> The {@link java.nio.file.FileRef#getAttribute getAttribute} method may be
|
||||
* used to read any of these attributes as if by invoking the {@link
|
||||
* #readAttributes() readAttributes()} method.
|
||||
*
|
||||
* <p> The {@link #setAttribute setAttribute} method may be used to update the
|
||||
* file's last modified time, last access time or create time attributes as if
|
||||
* by invoking the {@link #setTimes setTimes} method. In that case, the time
|
||||
* value is interpreted in {@link TimeUnit#MILLISECONDS milliseconds} and
|
||||
* converted to the precision supported by the file system.
|
||||
* <p> The {@link java.nio.file.FileRef#setAttribute setAttribute} method may be
|
||||
* used to update the file's last modified time, last access time or create time
|
||||
* attributes as if by invoking the {@link #setTimes setTimes} method.
|
||||
*
|
||||
* @since 1.7
|
||||
* @see Attributes
|
||||
@ -141,11 +129,11 @@ public interface BasicFileAttributeView
|
||||
* and create time attributes.
|
||||
*
|
||||
* <p> This method updates the file's timestamp attributes. The values are
|
||||
* measured since the epoch (00:00:00 GMT, January 1, 1970) and converted to
|
||||
* the precision supported by the file system. Converting from finer to
|
||||
* coarser granularities result in precision loss. If a value is larger
|
||||
* than the maximum supported by the file system then the corresponding
|
||||
* timestamp is set to its maximum value.
|
||||
* converted to the epoch and precision supported by the file system.
|
||||
* Converting from finer to coarser granularities result in precision loss.
|
||||
* The behavior of this method when attempting to set a timestamp to a value
|
||||
* that is outside the range supported by the underlying file store is not
|
||||
* defined. It may or not fail by throwing an {@code IOException}.
|
||||
*
|
||||
* <p> If any of the {@code lastModifiedTime}, {@code lastAccessTime},
|
||||
* or {@code createTime} parameters has the value {@code null} then the
|
||||
@ -153,25 +141,19 @@ public interface BasicFileAttributeView
|
||||
* read the existing values of the file attributes when only some, but not
|
||||
* all, of the timestamp attributes are updated. Consequently, this method
|
||||
* may not be an atomic operation with respect to other file system
|
||||
* operations. If all of the {@code lastModifiedTime}, {@code
|
||||
* operations. Reading and re-writing existing values may also result in
|
||||
* precision loss. If all of the {@code lastModifiedTime}, {@code
|
||||
* lastAccessTime} and {@code createTime} parameters are {@code null} then
|
||||
* this method has no effect.
|
||||
*
|
||||
* @param lastModifiedTime
|
||||
* the new last modified time, or {@code -1L} to update it to
|
||||
* the current time, or {@code null} to not change the attribute
|
||||
* the new last modified time, or {@code null} to not change the
|
||||
* value
|
||||
* @param lastAccessTime
|
||||
* the last access time, or {@code -1L} to update it to
|
||||
* the current time, or {@code null} to not change the attribute.
|
||||
* the last access time, or {@code null} to not change the value
|
||||
* @param createTime
|
||||
* the file's create time, or {@code -1L} to update it to
|
||||
* the current time, or {@code null} to not change the attribute
|
||||
* @param unit
|
||||
* a {@code TimeUnit} determining how to interpret the time values
|
||||
* the file's create time, or {@code null} to not change the value
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if any of the parameters is a negative value other than {@code
|
||||
* -1L}
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
@ -179,8 +161,7 @@ public interface BasicFileAttributeView
|
||||
* installed, its {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method is invoked to check write access to the file
|
||||
*/
|
||||
void setTimes(Long lastModifiedTime,
|
||||
Long lastAccessTime,
|
||||
Long createTime,
|
||||
TimeUnit unit) throws IOException;
|
||||
void setTimes(FileTime lastModifiedTime,
|
||||
FileTime lastAccessTime,
|
||||
FileTime createTime) throws IOException;
|
||||
}
|
||||
|
||||
@ -25,8 +25,6 @@
|
||||
|
||||
package java.nio.file.attribute;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Basic attributes associated with a file in a file system.
|
||||
*
|
||||
@ -50,47 +48,27 @@ public interface BasicFileAttributes {
|
||||
/**
|
||||
* Returns the time of last modification.
|
||||
*
|
||||
* <p> The {@link #resolution() resolution} method returns the {@link TimeUnit}
|
||||
* to interpret the return value of this method.
|
||||
*
|
||||
* @return a <code>long</code> value representing the time the file was
|
||||
* last modified since the epoch (00:00:00 GMT, January 1, 1970),
|
||||
* or {@code -1L} if the attribute is not supported.
|
||||
* @return a {@code FileTime} representing the time the file was last
|
||||
* modified or {@code null} if the attribute is not supported.
|
||||
*/
|
||||
long lastModifiedTime();
|
||||
FileTime lastModifiedTime();
|
||||
|
||||
/**
|
||||
* Returns the time of last access if supported.
|
||||
*
|
||||
* <p> The {@link #resolution() resolution} method returns the {@link TimeUnit}
|
||||
* to interpret the return value of this method.
|
||||
*
|
||||
* @return a <code>long</code> value representing the time of last access
|
||||
* since the epoch (00:00:00 GMT, January 1, 1970), or {@code -1L}
|
||||
* if the attribute is not supported.
|
||||
* @return a {@code FileTime} representing the time of last access or
|
||||
* {@code null} if the attribute is not supported.
|
||||
*/
|
||||
long lastAccessTime();
|
||||
FileTime lastAccessTime();
|
||||
|
||||
/**
|
||||
* Returns the creation time if supported. The creation time is the time
|
||||
* that the file was created.
|
||||
*
|
||||
* <p> The {@link #resolution() resolution} method returns the {@link TimeUnit}
|
||||
* to interpret the return value of this method.
|
||||
*
|
||||
* @return a <code>long</code> value representing the time the file was
|
||||
* created since the epoch (00:00:00 GMT, January 1, 1970), or
|
||||
* {@code -1L} if the attribute is not supported.
|
||||
* @return a {@code FileTime} representing the time the file was created
|
||||
* or {@code null} if the attribute is not supported.
|
||||
*/
|
||||
long creationTime();
|
||||
|
||||
/**
|
||||
* Returns the {@link TimeUnit} required to interpret the time of last
|
||||
* modification, time of last access, and creation time.
|
||||
*
|
||||
* @return the {@code TimeUnit} required to interpret the file time stamps
|
||||
*/
|
||||
TimeUnit resolution();
|
||||
FileTime creationTime();
|
||||
|
||||
/**
|
||||
* Tells whether the file is a regular file with opaque content.
|
||||
@ -124,18 +102,6 @@ public interface BasicFileAttributes {
|
||||
*/
|
||||
long size();
|
||||
|
||||
/**
|
||||
* Returns the number of <em>links</em> to this file.
|
||||
*
|
||||
* <p> On file systems where the same file may be in several directories then
|
||||
* the link count is the number of directory entries for the file. The return
|
||||
* value is {@code 1} on file systems that only allow a file to have a
|
||||
* single name in a single directory.
|
||||
*
|
||||
* @see java.nio.file.Path#createLink
|
||||
*/
|
||||
int linkCount();
|
||||
|
||||
/**
|
||||
* Returns an object that uniquely identifies the given file, or {@code
|
||||
* null} if a file key is not available. On some platforms or file systems
|
||||
@ -154,7 +120,7 @@ public interface BasicFileAttributes {
|
||||
*
|
||||
* <p> File keys returned by this method can be compared for equality and are
|
||||
* suitable for use in collections. If the file system and files remain static,
|
||||
* and two files are the {@link java.nio.file.FileRef#isSameFile same} with
|
||||
* and two files are the {@link java.nio.file.Path#isSameFile same} with
|
||||
* non-{@code null} file keys, then their file keys are equal.
|
||||
*
|
||||
* @see java.nio.file.Files#walkFileTree
|
||||
|
||||
@ -65,17 +65,17 @@ import java.io.IOException;
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> The {@link #getAttribute getAttribute} or {@link #readAttributes(String,String[])
|
||||
* readAttributes(String,String[])} methods may be used to read any of these
|
||||
* attributes, or any of the attributes defined by {@link BasicFileAttributeView}
|
||||
* as if by invoking the {@link #readAttributes readAttributes()} method.
|
||||
* <p> The {@link java.nio.file.FileRef#getAttribute getAttribute} method may
|
||||
* be used to read any of these attributes, or any of the attributes defined by
|
||||
* {@link BasicFileAttributeView} as if by invoking the {@link #readAttributes
|
||||
* readAttributes()} method.
|
||||
*
|
||||
* <p> The {@link #setAttribute setAttribute} method may be used to update the
|
||||
* file's last modified time, last access time or create time attributes as
|
||||
* defined by {@link BasicFileAttributeView}. It may also be used to update
|
||||
* the DOS attributes as if by invoking the {@link #setReadOnly setReadOnly},
|
||||
* {@link #setHidden setHidden}, {@link #setSystem setSystem}, and {@link
|
||||
* #setArchive setArchive} methods respectively.
|
||||
* <p> The {@link java.nio.file.FileRef#setAttribute setAttribute} method may
|
||||
* be used to update the file's last modified time, last access time or create
|
||||
* time attributes as defined by {@link BasicFileAttributeView}. It may also be
|
||||
* used to update the DOS attributes as if by invoking the {@link #setReadOnly
|
||||
* setReadOnly}, {@link #setHidden setHidden}, {@link #setSystem setSystem}, and
|
||||
* {@link #setArchive setArchive} methods respectively.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
@ -34,7 +34,6 @@ package java.nio.file.attribute;
|
||||
* @since 1.7
|
||||
*
|
||||
* @see java.nio.file.FileRef#getFileAttributeView(Class,java.nio.file.LinkOption[])
|
||||
* @see java.nio.file.FileRef#getFileAttributeView(String,java.nio.file.LinkOption[])
|
||||
*/
|
||||
|
||||
public interface FileAttributeView
|
||||
|
||||
@ -37,11 +37,11 @@ import java.io.IOException;
|
||||
* <p> The {@link #getOwner getOwner} or {@link #setOwner setOwner} methods may
|
||||
* be used to read or update the owner of the file.
|
||||
*
|
||||
* <p> Where dynamic access to file attributes is required, the owner attribute
|
||||
* is identified by the name {@code "owner"}, and the value of the attribute is
|
||||
* a {@link UserPrincipal}. The {@link #readAttributes readAttributes}, {@link
|
||||
* #getAttribute getAttribute} and {@link #setAttribute setAttributes} methods
|
||||
* may be used to read or update the file owner.
|
||||
* <p> The {@link java.nio.file.FileRef#getAttribute getAttribute} and
|
||||
* {@link java.nio.file.FileRef#setAttribute setAttribute} methods may also be
|
||||
* used to read or update the owner. In that case, the owner attribute is
|
||||
* identified by the name {@code "owner"}, and the value of the attribute is
|
||||
* a {@link UserPrincipal}.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
@ -52,10 +52,8 @@ import java.io.IOException;
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* <p> The {@link #getAttribute getAttribute} or {@link #readAttributes
|
||||
* readAttributes(String,String[])} methods may be used to read any of these
|
||||
* attributes as if by invoking the {@link #readAttributes readAttributes()}
|
||||
* method.
|
||||
* <p> The {@link java.nio.file.FileStore#getAttribute getAttribute} method may
|
||||
* be used to read any of these attributes.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
305
jdk/src/share/classes/java/nio/file/attribute/FileTime.java
Normal file
305
jdk/src/share/classes/java/nio/file/attribute/FileTime.java
Normal file
@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package java.nio.file.attribute;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Date;
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Represents the value of a file's time stamp attribute. For example, it may
|
||||
* represent the time that the file was last modified, accessed, or created.
|
||||
*
|
||||
* <p> Instances of this class are immutable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @see BasicFileAttributes
|
||||
* @see Attributes#setLastModifiedTime
|
||||
*/
|
||||
|
||||
public final class FileTime implements Comparable<FileTime> {
|
||||
private final long value;
|
||||
private final TimeUnit unit;
|
||||
private String valueAsString; // created lazily
|
||||
|
||||
private FileTime(long value, TimeUnit unit) {
|
||||
if (unit == null)
|
||||
throw new NullPointerException();
|
||||
this.value = value;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code FileTime} representing a value at the given unit of
|
||||
* granularity.
|
||||
*
|
||||
* @param value
|
||||
* the value since the epoch (1970-01-01T00:00:00Z); can be
|
||||
* negative
|
||||
* @param unit
|
||||
* the unit of granularity to interpret the value
|
||||
*
|
||||
* @return a {@code FileTime} representing the given value
|
||||
*/
|
||||
public static FileTime from(long value, TimeUnit unit) {
|
||||
return new FileTime(value, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code FileTime} representing the given value in milliseconds.
|
||||
*
|
||||
* @param value
|
||||
* the value, in milliseconds, since the epoch
|
||||
* (1970-01-01T00:00:00Z); can be negative
|
||||
*
|
||||
* @return a {@code FileTime} representing the given value
|
||||
*/
|
||||
public static FileTime fromMillis(long value) {
|
||||
return new FileTime(value, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at the given unit of granularity.
|
||||
*
|
||||
* <p> Conversion from a coarser granularity that would numerically overflow
|
||||
* saturate to {@code Long.MIN_VALUE} if negative or {@code Long.MAX_VALUE}
|
||||
* if positive.
|
||||
*
|
||||
* @param unit
|
||||
* the unit of granularity for the return value
|
||||
*
|
||||
* @return value in the given unit of granularity, since the epoch
|
||||
* since the epoch (1970-01-01T00:00:00Z); can be negative
|
||||
*/
|
||||
public long to(TimeUnit unit) {
|
||||
return unit.convert(this.value, this.unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value in milliseconds.
|
||||
*
|
||||
* <p> Conversion from a coarser granularity that would numerically overflow
|
||||
* saturate to {@code Long.MIN_VALUE} if negative or {@code Long.MAX_VALUE}
|
||||
* if positive.
|
||||
*
|
||||
* @return the value in milliseconds, since the epoch (1970-01-01T00:00:00Z)
|
||||
*/
|
||||
public long toMillis() {
|
||||
return unit.toMillis(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests this {@code FileTime} for equality with the given object.
|
||||
*
|
||||
* <p> The result is {@code true} if and only if the argument is not {@code
|
||||
* null} and is a {@code FileTime} that represents the same time. This
|
||||
* method satisfies the general contract of the {@code Object.equals} method.
|
||||
*
|
||||
* @param obj
|
||||
* the object to compare with
|
||||
*
|
||||
* @return {@code true} if, and only if, the given object is a {@code
|
||||
* FileTime} that represents the same time
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof FileTime) ? compareTo((FileTime)obj) == 0 : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a hash code for this file time.
|
||||
*
|
||||
* <p> The hash code is based upon the value represented, and satisfies the
|
||||
* general contract of the {@link Object#hashCode} method.
|
||||
*
|
||||
* @return the hash-code value
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// hash value for fixed granularity to satisfy contract with equals
|
||||
long ms = toMillis();
|
||||
return (int)(ms ^ (ms >>> 32));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the value of two {@code FileTime} objects for order.
|
||||
*
|
||||
* @param other
|
||||
* the other {@code FileTime} to be compared
|
||||
*
|
||||
* @return {@code 0} if this {@code FileTime} is equal to {@code other}, a
|
||||
* value less than 0 if this {@code FileTime} represents a time
|
||||
* that is before {@code other}, and a value greater than 0 if this
|
||||
* {@code FileTime} represents a time that is after {@code other}
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(FileTime other) {
|
||||
// same granularity
|
||||
if (unit == other.unit)
|
||||
return (value < other.value) ? -1 : (value == other.value ? 0 : 1);
|
||||
|
||||
// compare in days
|
||||
long thisValueInDays = unit.toDays(value);
|
||||
long otherValueInDays = other.unit.toDays(other.value);
|
||||
if (thisValueInDays != otherValueInDays)
|
||||
return (thisValueInDays < otherValueInDays) ? -1 : 1;
|
||||
|
||||
// compare remainder in nanoseconds
|
||||
long thisRemainder = remainderInNanos(thisValueInDays);
|
||||
long otherRemainder = other.remainderInNanos(otherValueInDays);
|
||||
return (thisRemainder < otherRemainder) ? -1 :
|
||||
(thisRemainder == otherRemainder) ? 0 : 1;
|
||||
}
|
||||
|
||||
private long remainderInNanos(long days) {
|
||||
// constants for conversion
|
||||
final long C0 = 1L;
|
||||
final long C1 = C0 * 24L;
|
||||
final long C2 = C1 * 60L;
|
||||
final long C3 = C2 * 60L;
|
||||
final long C4 = C3 * 1000L;
|
||||
final long C5 = C4 * 1000L;
|
||||
final long C6 = C5 * 1000L;
|
||||
|
||||
long scale;
|
||||
switch (unit) {
|
||||
case DAYS : scale = C0; break;
|
||||
case HOURS : scale = C1; break;
|
||||
case MINUTES : scale = C2; break;
|
||||
case SECONDS : scale = C3; break;
|
||||
case MILLISECONDS : scale = C4; break;
|
||||
case MICROSECONDS : scale = C5; break;
|
||||
case NANOSECONDS : scale = C6; break;
|
||||
default:
|
||||
throw new AssertionError("Unit not handled");
|
||||
}
|
||||
long rem = value - (days * scale);
|
||||
return unit.toNanos(rem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this {@code FileTime}. The string
|
||||
* is returned in the <a
|
||||
* href="http://www.w3.org/TR/NOTE-datetime">ISO 8601</a> format:
|
||||
* <pre>
|
||||
* YYYY-MM-DDThh:mm:ss[.s+]Z
|
||||
* </pre>
|
||||
* where "{@code [.s+]}" represents a dot followed by one of more digits
|
||||
* for the decimal fraction of a second. It is only present when the decimal
|
||||
* fraction of a second is not zero. For example, {@code
|
||||
* FileTime.fromMillis(1234567890000L).toString()} yields {@code
|
||||
* "2009-02-13T23:31:30Z"}, and {@code FileTime.fromMillis(1234567890123L).toString()}
|
||||
* yields {@code "2009-02-13T23:31:30.123Z"}.
|
||||
*
|
||||
* <p> A {@code FileTime} is primarly intended to represent the value of a
|
||||
* file's time stamp. Where used to represent <i>extreme values</i>, where
|
||||
* the year is less than "{@code 0001}" or greater than "{@code 9999}" then
|
||||
* the year may be expanded to more than four digits and may be
|
||||
* negative-signed. If more than four digits then leading zeros are not
|
||||
* present. The year before "{@code 0001}" is "{@code -0001}".
|
||||
*
|
||||
* @return the string representation of this file time
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String v = valueAsString;
|
||||
if (v == null) {
|
||||
// overflow saturates to Long.MIN_VALUE or Long.MAX_VALUE so this
|
||||
// limits the range:
|
||||
// [-292275056-05-16T16:47:04.192Z,292278994-08-17T07:12:55.807Z]
|
||||
long ms = toMillis();
|
||||
|
||||
// nothing to do when seconds/minutes/hours/days
|
||||
String fractionAsString = "";
|
||||
if (unit.compareTo(TimeUnit.SECONDS) < 0) {
|
||||
// constants for conversion
|
||||
final long C0 = 1L;
|
||||
final long C1 = C0 * 1000L;
|
||||
final long C2 = C1 * 1000L;
|
||||
final long C3 = C2 * 1000L;
|
||||
|
||||
long scale;
|
||||
int width;
|
||||
switch (unit) {
|
||||
case MILLISECONDS : scale = C1; width = 3; break;
|
||||
case MICROSECONDS : scale = C2; width = 6; break;
|
||||
case NANOSECONDS : scale = C3; width = 9; break;
|
||||
default:
|
||||
throw new AssertionError("Unit not handled");
|
||||
}
|
||||
long fraction = value % scale;
|
||||
if (fraction != 0L) {
|
||||
// fraction must be positive
|
||||
if (fraction < 0L) {
|
||||
fraction += scale;
|
||||
if (ms != Long.MIN_VALUE) ms--;
|
||||
}
|
||||
|
||||
// convert to String, adding leading zeros as required and
|
||||
// stripping any trailing zeros
|
||||
String s = Long.toString(fraction);
|
||||
int len = s.length();
|
||||
width -= len;
|
||||
StringBuilder sb = new StringBuilder(".");
|
||||
while (width-- > 0) {
|
||||
sb.append('0');
|
||||
}
|
||||
if (s.charAt(len-1) == '0') {
|
||||
// drop trailing zeros
|
||||
len--;
|
||||
while (s.charAt(len-1) == '0')
|
||||
len--;
|
||||
sb.append(s.substring(0, len));
|
||||
} else {
|
||||
sb.append(s);
|
||||
}
|
||||
fractionAsString = sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
// create calendar to use with formatter.
|
||||
GregorianCalendar cal =
|
||||
new GregorianCalendar(TimeZone.getTimeZone("UTC"), Locale.ROOT);
|
||||
if (value < 0L)
|
||||
cal.setGregorianChange(new Date(Long.MIN_VALUE));
|
||||
cal.setTimeInMillis(ms);
|
||||
|
||||
// years are negative before common era
|
||||
String sign = (cal.get(Calendar.ERA) == GregorianCalendar.BC) ? "-" : "";
|
||||
|
||||
// [-]YYYY-MM-DDThh:mm:ss[.s]Z
|
||||
v = new Formatter(Locale.ROOT)
|
||||
.format("%s%tFT%tR:%tS%sZ", sign, cal, cal, cal, fractionAsString)
|
||||
.toString();
|
||||
valueAsString = v;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
}
|
||||
@ -90,14 +90,13 @@ import java.io.IOException;
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* <p> The {@link #getAttribute getAttribute} or {@link
|
||||
* #readAttributes(String,String[]) readAttributes(String,String[])} methods may
|
||||
* be used to read any of these attributes, or any of the attributes defined by
|
||||
* {@link BasicFileAttributeView} as if by invoking the {@link #readAttributes
|
||||
* <p> The {@link FileRef#getAttribute getAttribute} method may be used to read
|
||||
* any of these attributes, or any of the attributes defined by {@link
|
||||
* BasicFileAttributeView} as if by invoking the {@link #readAttributes
|
||||
* readAttributes()} method.
|
||||
*
|
||||
* <p> The {@link #setAttribute setAttribute} method may be used to update the
|
||||
* file's last modified time, last access time or create time attributes as
|
||||
* <p> The {@link FileRef#setAttribute setAttribute} method may be used to update
|
||||
* the file's last modified time, last access time or create time attributes as
|
||||
* defined by {@link BasicFileAttributeView}. It may also be used to update
|
||||
* the permissions, owner, or group-owner as if by invoking the {@link
|
||||
* #setPermissions setPermissions}, {@link #setOwner setOwner}, and {@link
|
||||
|
||||
@ -35,7 +35,7 @@ import java.util.*;
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public class PosixFilePermissions {
|
||||
public final class PosixFilePermissions {
|
||||
private PosixFilePermissions() { }
|
||||
|
||||
// Write string representation of permission bits to {@code sb}.
|
||||
@ -58,7 +58,9 @@ public class PosixFilePermissions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code String} representation of a set of permissions.
|
||||
* Returns the {@code String} representation of a set of permissions. It
|
||||
* is guaranteed that the returned {@code String} can be parsed by the
|
||||
* {@link #fromString} method.
|
||||
*
|
||||
* <p> If the set contains {@code null} or elements that are not of type
|
||||
* {@code PosixFilePermission} then these elements are ignored.
|
||||
@ -67,8 +69,6 @@ public class PosixFilePermissions {
|
||||
* the set of permissions
|
||||
*
|
||||
* @return the string representation of the permission set
|
||||
*
|
||||
* @see #fromString
|
||||
*/
|
||||
public static String toString(Set<PosixFilePermission> perms) {
|
||||
StringBuilder sb = new StringBuilder(9);
|
||||
|
||||
@ -59,12 +59,11 @@ import java.io.IOException;
|
||||
* attributes.
|
||||
*
|
||||
* <p> Where dynamic access to file attributes is required, the {@link
|
||||
* #getAttribute getAttribute} or {@link #readAttributes(String,String[])
|
||||
* readAttributes(String,String[])} methods may be used to read the attribute
|
||||
* value. The attribute value is returned as a byte array (byte[]). The {@link
|
||||
* #setAttribute setAttribute} method may be used to write the value of a
|
||||
* user-defined attribute from a buffer (as if by invoking the {@link #write
|
||||
* write} method), or byte array (byte[]).
|
||||
* java.nio.file.FileRef#getAttribute getAttribute} method may be used to read
|
||||
* the attribute value. The attribute value is returned as a byte array (byte[]).
|
||||
* The {@link java.nio.file.FileRef#setAttribute setAttribute} method may be used
|
||||
* to write the value of a user-defined attribute from a buffer (as if by
|
||||
* invoking the {@link #write write} method), or byte array (byte[]).
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
@ -74,7 +73,7 @@ public interface UserDefinedFileAttributeView
|
||||
{
|
||||
/**
|
||||
* Returns the name of this attribute view. Attribute views of this type
|
||||
* have the name {@code "xattr"}.
|
||||
* have the name {@code "user"}.
|
||||
*/
|
||||
@Override
|
||||
String name();
|
||||
|
||||
@ -89,7 +89,7 @@ public abstract class UserPrincipalLookupService {
|
||||
* @param group
|
||||
* the string representation of the group to lookup
|
||||
*
|
||||
* @return a user principal
|
||||
* @return a group principal
|
||||
*
|
||||
* @throws UserPrincipalNotFoundException
|
||||
* the principal does not exist or is not a group
|
||||
|
||||
@ -1,568 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package java.nio.file.spi;
|
||||
|
||||
import java.nio.file.*;
|
||||
import static java.nio.file.StandardOpenOption.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.nio.channels.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Base implementation class for a {@code Path}.
|
||||
*
|
||||
* <p> This class is intended to be extended by provider implementors. It
|
||||
* implements, or provides default implementations for several of the methods
|
||||
* defined by the {@code Path} class. It implements the {@link #copyTo copyTo}
|
||||
* and {@link #moveTo moveTo} methods for the case that the source and target
|
||||
* are not associated with the same provider.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
public abstract class AbstractPath extends Path {
|
||||
|
||||
/**
|
||||
* Initializes a new instance of this class.
|
||||
*/
|
||||
protected AbstractPath() { }
|
||||
|
||||
/**
|
||||
* Deletes the file referenced by this object.
|
||||
*
|
||||
* <p> This method invokes the {@link #delete(boolean) delete(boolean)}
|
||||
* method with a parameter of {@code true}. It may be overridden where
|
||||
* required.
|
||||
*
|
||||
* @throws NoSuchFileException {@inheritDoc}
|
||||
* @throws DirectoryNotEmptyException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void delete() throws IOException {
|
||||
delete(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new and empty file, failing if the file already exists.
|
||||
*
|
||||
* <p> This method invokes the {@link #newByteChannel(Set,FileAttribute[])
|
||||
* newByteChannel(Set,FileAttribute...)} method to create the file. It may be
|
||||
* overridden where required.
|
||||
*
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws FileAlreadyExistsException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Path createFile(FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
EnumSet<StandardOpenOption> options = EnumSet.of(CREATE_NEW, WRITE);
|
||||
SeekableByteChannel sbc = newByteChannel(options, attrs);
|
||||
try {
|
||||
sbc.close();
|
||||
} catch (IOException x) {
|
||||
// ignore
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or creates a file, returning a seekable byte channel to access the
|
||||
* file.
|
||||
*
|
||||
* <p> This method invokes the {@link #newByteChannel(Set,FileAttribute[])
|
||||
* newByteChannel(Set,FileAttribute...)} method to open or create the file.
|
||||
* It may be overridden where required.
|
||||
*
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws FileAlreadyExistsException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SeekableByteChannel newByteChannel(OpenOption... options)
|
||||
throws IOException
|
||||
{
|
||||
Set<OpenOption> set = new HashSet<OpenOption>(options.length);
|
||||
Collections.addAll(set, options);
|
||||
return newByteChannel(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the file located by this path for reading, returning an input
|
||||
* stream to read bytes from the file.
|
||||
*
|
||||
* <p> This method returns an {@code InputStream} that is constructed by
|
||||
* invoking the {@link java.nio.channels.Channels#newInputStream
|
||||
* Channels.newInputStream} method. It may be overridden where a more
|
||||
* efficient implementation is available.
|
||||
*
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public InputStream newInputStream() throws IOException {
|
||||
return Channels.newInputStream(newByteChannel());
|
||||
}
|
||||
|
||||
// opts must be modifiable
|
||||
private OutputStream implNewOutputStream(Set<OpenOption> opts,
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
if (opts.isEmpty()) {
|
||||
opts.add(CREATE);
|
||||
opts.add(TRUNCATE_EXISTING);
|
||||
} else {
|
||||
if (opts.contains(READ))
|
||||
throw new IllegalArgumentException("READ not allowed");
|
||||
}
|
||||
opts.add(WRITE);
|
||||
return Channels.newOutputStream(newByteChannel(opts, attrs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or creates the file located by this path for writing, returning an
|
||||
* output stream to write bytes to the file.
|
||||
*
|
||||
* <p> This method returns an {@code OutputStream} that is constructed by
|
||||
* invoking the {@link java.nio.channels.Channels#newOutputStream
|
||||
* Channels.newOutputStream} method. It may be overridden where a more
|
||||
* efficient implementation is available.
|
||||
*
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public OutputStream newOutputStream(OpenOption... options) throws IOException {
|
||||
int len = options.length;
|
||||
Set<OpenOption> opts = new HashSet<OpenOption>(len + 3);
|
||||
if (len > 0) {
|
||||
for (OpenOption opt: options) {
|
||||
opts.add(opt);
|
||||
}
|
||||
}
|
||||
return implNewOutputStream(opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens or creates the file located by this path for writing, returning an
|
||||
* output stream to write bytes to the file.
|
||||
*
|
||||
* <p> This method returns an {@code OutputStream} that is constructed by
|
||||
* invoking the {@link java.nio.channels.Channels#newOutputStream
|
||||
* Channels.newOutputStream} method. It may be overridden where a more
|
||||
* efficient implementation is available.
|
||||
*
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public OutputStream newOutputStream(Set<? extends OpenOption> options,
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
Set<OpenOption> opts = new HashSet<OpenOption>(options);
|
||||
return implNewOutputStream(opts, attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the directory referenced by this object, returning a {@code
|
||||
* DirectoryStream} to iterate over all entries in the directory.
|
||||
*
|
||||
* <p> This method invokes the {@link
|
||||
* #newDirectoryStream(java.nio.file.DirectoryStream.Filter)
|
||||
* newDirectoryStream(Filter)} method with a filter that accept all entries.
|
||||
* It may be overridden where required.
|
||||
*
|
||||
* @throws NotDirectoryException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public DirectoryStream<Path> newDirectoryStream() throws IOException {
|
||||
return newDirectoryStream(acceptAllFilter);
|
||||
}
|
||||
private static final DirectoryStream.Filter<Path> acceptAllFilter =
|
||||
new DirectoryStream.Filter<Path>() {
|
||||
@Override public boolean accept(Path entry) { return true; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens the directory referenced by this object, returning a {@code
|
||||
* DirectoryStream} to iterate over the entries in the directory. The
|
||||
* entries are filtered by matching the {@code String} representation of
|
||||
* their file names against a given pattern.
|
||||
*
|
||||
* <p> This method constructs a {@link PathMatcher} by invoking the
|
||||
* file system's {@link java.nio.file.FileSystem#getPathMatcher
|
||||
* getPathMatcher} method. This method may be overridden where a more
|
||||
* efficient implementation is available.
|
||||
*
|
||||
* @throws java.util.regex.PatternSyntaxException {@inheritDoc}
|
||||
* @throws UnsupportedOperationException {@inheritDoc}
|
||||
* @throws NotDirectoryException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public DirectoryStream<Path> newDirectoryStream(String glob)
|
||||
throws IOException
|
||||
{
|
||||
// avoid creating a matcher if all entries are required.
|
||||
if (glob.equals("*"))
|
||||
return newDirectoryStream();
|
||||
|
||||
// create a matcher and return a filter that uses it.
|
||||
final PathMatcher matcher = getFileSystem().getPathMatcher("glob:" + glob);
|
||||
DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
|
||||
@Override
|
||||
public boolean accept(Path entry) {
|
||||
return matcher.matches(entry.getName());
|
||||
}
|
||||
};
|
||||
return newDirectoryStream(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the file located by this path exists.
|
||||
*
|
||||
* <p> This method invokes the {@link #checkAccess checkAccess} method to
|
||||
* check if the file exists. It may be overridden where a more efficient
|
||||
* implementation is available.
|
||||
*/
|
||||
@Override
|
||||
public boolean exists() {
|
||||
try {
|
||||
checkAccess();
|
||||
return true;
|
||||
} catch (IOException x) {
|
||||
// unable to determine if file exists
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the file located by this path does not exist.
|
||||
*
|
||||
* <p> This method invokes the {@link #checkAccess checkAccess} method to
|
||||
* check if the file exists. It may be overridden where a more efficient
|
||||
* implementation is available.
|
||||
*/
|
||||
@Override
|
||||
public boolean notExists() {
|
||||
try {
|
||||
checkAccess();
|
||||
return false;
|
||||
} catch (NoSuchFileException x) {
|
||||
// file confirmed not to exist
|
||||
return true;
|
||||
} catch (IOException x) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the file located by this path with a watch service.
|
||||
*
|
||||
* <p> This method invokes the {@link #register(WatchService,WatchEvent.Kind[],WatchEvent.Modifier[])
|
||||
* register(WatchService,WatchEvent.Kind[],WatchEvent.Modifier...)}
|
||||
* method to register the file. It may be overridden where required.
|
||||
*/
|
||||
@Override
|
||||
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events)
|
||||
throws IOException
|
||||
{
|
||||
return register(watcher, events, NO_MODIFIERS);
|
||||
}
|
||||
private static final WatchEvent.Modifier[] NO_MODIFIERS = new WatchEvent.Modifier[0];
|
||||
|
||||
/**
|
||||
* Copy the file located by this path to a target location.
|
||||
*
|
||||
* <p> This method is invoked by the {@link #copyTo copyTo} method for
|
||||
* the case that this {@code Path} and the target {@code Path} are
|
||||
* associated with the same provider.
|
||||
*
|
||||
* @param target
|
||||
* The target location
|
||||
* @param options
|
||||
* Options specifying how the copy should be done
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If an invalid option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* The target file exists and cannot be replaced because the
|
||||
* {@code REPLACE_EXISTING} option is not specified, or the target
|
||||
* file is a non-empty directory <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkRead(String) checkRead}
|
||||
* method is invoked to check read access to the source file, the
|
||||
* {@link SecurityManager#checkWrite(String) checkWrite} is invoked
|
||||
* to check write access to the target file. If a symbolic link is
|
||||
* copied the security manager is invoked to check {@link
|
||||
* LinkPermission}{@code ("symbolic")}.
|
||||
*/
|
||||
protected abstract void implCopyTo(Path target, CopyOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Move the file located by this path to a target location.
|
||||
*
|
||||
* <p> This method is invoked by the {@link #moveTo moveTo} method for
|
||||
* the case that this {@code Path} and the target {@code Path} are
|
||||
* associated with the same provider.
|
||||
*
|
||||
* @param target
|
||||
* The target location
|
||||
* @param options
|
||||
* Options specifying how the move should be done
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If an invalid option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* The target file exists and cannot be replaced because the
|
||||
* {@code REPLACE_EXISTING} option is not specified, or the target
|
||||
* file is a non-empty directory
|
||||
* @throws AtomicMoveNotSupportedException
|
||||
* The options array contains the {@code ATOMIC_MOVE} option but
|
||||
* the file cannot be moved as an atomic file system operation.
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
* method is invoked to check write access to both the source and
|
||||
* target file.
|
||||
*/
|
||||
protected abstract void implMoveTo(Path target, CopyOption... options)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Copy the file located by this path to a target location.
|
||||
*
|
||||
* <p> If this path is associated with the same {@link FileSystemProvider
|
||||
* provider} as the {@code target} then the {@link #implCopyTo implCopyTo}
|
||||
* method is invoked to copy the file. Otherwise, this method attempts to
|
||||
* copy the file to the target location in a manner that may be less
|
||||
* efficient than would be the case that target is associated with the same
|
||||
* provider as this path.
|
||||
*
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws FileAlreadyExistsException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final Path copyTo(Path target, CopyOption... options)
|
||||
throws IOException
|
||||
{
|
||||
if ((getFileSystem().provider() == target.getFileSystem().provider())) {
|
||||
implCopyTo(target, options);
|
||||
} else {
|
||||
xProviderCopyTo(target, options);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move or rename the file located by this path to a target location.
|
||||
*
|
||||
* <p> If this path is associated with the same {@link FileSystemProvider
|
||||
* provider} as the {@code target} then the {@link #implCopyTo implMoveTo}
|
||||
* method is invoked to move the file. Otherwise, this method attempts to
|
||||
* copy the file to the target location and delete the source file. This
|
||||
* implementation may be less efficient than would be the case that
|
||||
* target is associated with the same provider as this path.
|
||||
*
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @throws FileAlreadyExistsException {@inheritDoc}
|
||||
* @throws IOException {@inheritDoc}
|
||||
* @throws SecurityException {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public final Path moveTo(Path target, CopyOption... options)
|
||||
throws IOException
|
||||
{
|
||||
if ((getFileSystem().provider() == target.getFileSystem().provider())) {
|
||||
implMoveTo(target, options);
|
||||
} else {
|
||||
// different providers so copy + delete
|
||||
xProviderCopyTo(target, convertMoveToCopyOptions(options));
|
||||
delete(false);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given array of options for moving a file to options suitable
|
||||
* for copying the file when a move is implemented as copy + delete.
|
||||
*/
|
||||
private static CopyOption[] convertMoveToCopyOptions(CopyOption... options)
|
||||
throws AtomicMoveNotSupportedException
|
||||
{
|
||||
int len = options.length;
|
||||
CopyOption[] newOptions = new CopyOption[len+2];
|
||||
for (int i=0; i<len; i++) {
|
||||
CopyOption option = options[i];
|
||||
if (option == StandardCopyOption.ATOMIC_MOVE) {
|
||||
throw new AtomicMoveNotSupportedException(null, null,
|
||||
"Atomic move between providers is not supported");
|
||||
}
|
||||
newOptions[i] = option;
|
||||
}
|
||||
newOptions[len] = LinkOption.NOFOLLOW_LINKS;
|
||||
newOptions[len+1] = StandardCopyOption.COPY_ATTRIBUTES;
|
||||
return newOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the arguments for a file copy operation.
|
||||
*/
|
||||
private static class CopyOptions {
|
||||
boolean replaceExisting = false;
|
||||
boolean copyAttributes = false;
|
||||
boolean followLinks = true;
|
||||
|
||||
private CopyOptions() { }
|
||||
|
||||
static CopyOptions parse(CopyOption... options) {
|
||||
CopyOptions result = new CopyOptions();
|
||||
for (CopyOption option: options) {
|
||||
if (option == StandardCopyOption.REPLACE_EXISTING) {
|
||||
result.replaceExisting = true;
|
||||
continue;
|
||||
}
|
||||
if (option == LinkOption.NOFOLLOW_LINKS) {
|
||||
result.followLinks = false;
|
||||
continue;
|
||||
}
|
||||
if (option == StandardCopyOption.COPY_ATTRIBUTES) {
|
||||
result.copyAttributes = true;
|
||||
continue;
|
||||
}
|
||||
if (option == null)
|
||||
throw new NullPointerException();
|
||||
throw new IllegalArgumentException("'" + option +
|
||||
"' is not a valid copy option");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple cross-provider copy where the target is a Path.
|
||||
*/
|
||||
private void xProviderCopyTo(Path target, CopyOption... options)
|
||||
throws IOException
|
||||
{
|
||||
CopyOptions opts = CopyOptions.parse(options);
|
||||
LinkOption[] linkOptions = (opts.followLinks) ? new LinkOption[0] :
|
||||
new LinkOption[] { LinkOption.NOFOLLOW_LINKS };
|
||||
|
||||
// attributes of source file
|
||||
BasicFileAttributes attrs = Attributes
|
||||
.readBasicFileAttributes(this, linkOptions);
|
||||
if (attrs.isSymbolicLink())
|
||||
throw new IOException("Copying of symbolic links not supported");
|
||||
|
||||
// delete target file
|
||||
if (opts.replaceExisting)
|
||||
target.delete(false);
|
||||
|
||||
// create directory or file
|
||||
if (attrs.isDirectory()) {
|
||||
target.createDirectory();
|
||||
} else {
|
||||
xProviderCopyRegularFileTo(target);
|
||||
}
|
||||
|
||||
// copy basic attributes to target
|
||||
if (opts.copyAttributes) {
|
||||
BasicFileAttributeView view = target
|
||||
.getFileAttributeView(BasicFileAttributeView.class, linkOptions);
|
||||
try {
|
||||
view.setTimes(attrs.lastModifiedTime(),
|
||||
attrs.lastAccessTime(),
|
||||
attrs.creationTime(),
|
||||
attrs.resolution());
|
||||
} catch (IOException x) {
|
||||
// rollback
|
||||
try {
|
||||
target.delete(false);
|
||||
} catch (IOException ignore) { }
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simple copy of regular file to a target file that exists.
|
||||
*/
|
||||
private void xProviderCopyRegularFileTo(FileRef target)
|
||||
throws IOException
|
||||
{
|
||||
ReadableByteChannel rbc = newByteChannel();
|
||||
try {
|
||||
// open target file for writing
|
||||
SeekableByteChannel sbc = target.newByteChannel(CREATE, WRITE);
|
||||
|
||||
// simple copy loop
|
||||
try {
|
||||
ByteBuffer buf = ByteBuffer.wrap(new byte[8192]);
|
||||
int n = 0;
|
||||
for (;;) {
|
||||
n = rbc.read(buf);
|
||||
if (n < 0)
|
||||
break;
|
||||
assert n > 0;
|
||||
buf.flip();
|
||||
while (buf.hasRemaining()) {
|
||||
sbc.write(buf);
|
||||
}
|
||||
buf.rewind();
|
||||
}
|
||||
|
||||
} finally {
|
||||
sbc.close();
|
||||
}
|
||||
} finally {
|
||||
rbc.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,7 +270,9 @@ public abstract class FileSystemProvider {
|
||||
public abstract FileSystem getFileSystem(URI uri);
|
||||
|
||||
/**
|
||||
* Return a {@code Path} object by converting the given {@link URI}.
|
||||
* Return a {@code Path} object by converting the given {@link URI}. The
|
||||
* resulting {@code Path} is associated with a {@link FileSystem} that
|
||||
* already exists or is constructed automatically.
|
||||
*
|
||||
* <p> The exact form of the URI is file system provider dependent. In the
|
||||
* case of the default provider, the URI scheme is {@code "file"} and the
|
||||
@ -290,7 +292,8 @@ public abstract class FileSystemProvider {
|
||||
* If the URI scheme does not identify this provider or other
|
||||
* preconditions on the uri parameter do not hold
|
||||
* @throws FileSystemNotFoundException
|
||||
* The file system, identified by the URI, does not exist
|
||||
* The file system, identified by the URI, does not exist and
|
||||
* cannot be created automatically
|
||||
* @throws SecurityException
|
||||
* If a security manager is installed and it denies an unspecified
|
||||
* permission.
|
||||
|
||||
@ -690,7 +690,7 @@ public final class Scanner implements Iterator<String> {
|
||||
public Scanner(FileRef source)
|
||||
throws IOException
|
||||
{
|
||||
this(source.newByteChannel());
|
||||
this(source.newInputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -713,7 +713,7 @@ public final class Scanner implements Iterator<String> {
|
||||
public Scanner(FileRef source, String charsetName)
|
||||
throws IOException
|
||||
{
|
||||
this(source.newByteChannel(), charsetName);
|
||||
this(source.newInputStream(), charsetName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -43,18 +43,18 @@ class Adler32 implements Checksum {
|
||||
public Adler32() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates checksum with specified byte.
|
||||
* Updates the checksum with the specified byte (the low eight
|
||||
* bits of the argument b).
|
||||
*
|
||||
* @param b an array of bytes
|
||||
* @param b the byte to update the checksum with
|
||||
*/
|
||||
public void update(int b) {
|
||||
adler = update(adler, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates checksum with specified array of bytes.
|
||||
* Updates the checksum with the specified array of bytes.
|
||||
*/
|
||||
public void update(byte[] b, int off, int len) {
|
||||
if (b == null) {
|
||||
@ -67,21 +67,23 @@ class Adler32 implements Checksum {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates checksum with specified array of bytes.
|
||||
* Updates the checksum with the specified array of bytes.
|
||||
*
|
||||
* @param b the byte array to update the checksum with
|
||||
*/
|
||||
public void update(byte[] b) {
|
||||
adler = updateBytes(adler, b, 0, b.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets checksum to initial value.
|
||||
* Resets the checksum to initial value.
|
||||
*/
|
||||
public void reset() {
|
||||
adler = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns checksum value.
|
||||
* Returns the checksum value.
|
||||
*/
|
||||
public long getValue() {
|
||||
return (long)adler & 0xffffffffL;
|
||||
|
||||
@ -43,14 +43,17 @@ class CRC32 implements Checksum {
|
||||
|
||||
|
||||
/**
|
||||
* Updates CRC-32 with specified byte.
|
||||
* Updates the CRC-32 checksum with the specified byte (the low
|
||||
* eight bits of the argument b).
|
||||
*
|
||||
* @param b the byte to update the checksum with
|
||||
*/
|
||||
public void update(int b) {
|
||||
crc = update(crc, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates CRC-32 with specified array of bytes.
|
||||
* Updates the CRC-32 checksum with the specified array of bytes.
|
||||
*/
|
||||
public void update(byte[] b, int off, int len) {
|
||||
if (b == null) {
|
||||
@ -63,7 +66,7 @@ class CRC32 implements Checksum {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates checksum with specified array of bytes.
|
||||
* Updates the CRC-32 checksum with the specified array of bytes.
|
||||
*
|
||||
* @param b the array of bytes to update the checksum with
|
||||
*/
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package java.util.zip;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.EOFException;
|
||||
@ -47,7 +48,7 @@ import static java.util.zip.ZipConstants64.*;
|
||||
* @author David Connelly
|
||||
*/
|
||||
public
|
||||
class ZipFile implements ZipConstants {
|
||||
class ZipFile implements ZipConstants, Closeable {
|
||||
private long jzfile; // address of jzfile data
|
||||
private String name; // zip file name
|
||||
private int total; // total number of entries
|
||||
@ -248,6 +249,25 @@ class ZipFile implements ZipConstants {
|
||||
this(file, OPEN_READ, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the zip file comment, or null if none.
|
||||
*
|
||||
* @return the comment string for the zip file, or null if none
|
||||
*
|
||||
* @throws IllegalStateException if the zip file has been closed
|
||||
*
|
||||
* Since 1.7
|
||||
*/
|
||||
public String getComment() {
|
||||
synchronized (this) {
|
||||
ensureOpen();
|
||||
byte[] bcomm = getCommentBytes(jzfile);
|
||||
if (bcomm == null)
|
||||
return null;
|
||||
return zc.toString(bcomm, bcomm.length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the zip file entry for the specified name, or null
|
||||
* if not found.
|
||||
@ -663,6 +683,7 @@ class ZipFile implements ZipConstants {
|
||||
private static native long getEntrySize(long jzentry);
|
||||
private static native int getEntryMethod(long jzentry);
|
||||
private static native int getEntryFlag(long jzentry);
|
||||
private static native byte[] getCommentBytes(long jzfile);
|
||||
|
||||
private static final int JZENTRY_NAME = 0;
|
||||
private static final int JZENTRY_EXTRA = 1;
|
||||
|
||||
@ -25,26 +25,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.EUC_CN;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert EUC_CN to Unicode
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class ByteToCharEUC_CN extends ByteToCharDBCS_ASCII {
|
||||
|
||||
public class ByteToCharEUC_CN extends ByteToCharDoubleByte {
|
||||
|
||||
private EUC_CN nioCoder = new EUC_CN();
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new EUC_CN().newDecoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "EUC_CN";
|
||||
}
|
||||
|
||||
public ByteToCharEUC_CN() {
|
||||
super.index1 = nioCoder.getDecoderIndex1();
|
||||
super.index2 = nioCoder.getDecoderIndex2();
|
||||
start = 0xA1;
|
||||
end = 0xFE;
|
||||
super(dec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,26 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.EUC_KR;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert EUC_KR to Unicode
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class ByteToCharEUC_KR extends ByteToCharDBCS_ASCII {
|
||||
|
||||
public class ByteToCharEUC_KR extends ByteToCharDoubleByte {
|
||||
|
||||
private final static EUC_KR nioCoder = new EUC_KR();
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new EUC_KR().newDecoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "EUC_KR";
|
||||
}
|
||||
|
||||
public ByteToCharEUC_KR() {
|
||||
super.index1 = nioCoder.getDecoderIndex1();
|
||||
super.index2 = nioCoder.getDecoderIndex2();
|
||||
start = 0xA1;
|
||||
end = 0xFE;
|
||||
super(dec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,26 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.GBK;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert GBK to Unicode
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class ByteToCharGBK extends ByteToCharDBCS_ASCII {
|
||||
|
||||
public class ByteToCharGBK extends ByteToCharDoubleByte {
|
||||
|
||||
private final static GBK nioCoder = new GBK();
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new GBK().newDecoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "GBK";
|
||||
}
|
||||
|
||||
public ByteToCharGBK() {
|
||||
super.index1 = nioCoder.getDecoderIndex1();
|
||||
super.index2 = nioCoder.getDecoderIndex2();
|
||||
start = 0x40;
|
||||
end = 0xFE;
|
||||
super(dec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,26 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.Johab;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Johab to Unicode
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class ByteToCharJohab extends ByteToCharDBCS_ASCII {
|
||||
|
||||
public class ByteToCharJohab extends ByteToCharDoubleByte {
|
||||
|
||||
private final static Johab nioCoder = new Johab();
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new Johab().newDecoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "Johab";
|
||||
}
|
||||
|
||||
public ByteToCharJohab() {
|
||||
super.index1 = nioCoder.getDecoderIndex1();
|
||||
super.index2 = nioCoder.getDecoderIndex2();
|
||||
start = 0x20;
|
||||
end = 0xFE;
|
||||
super(dec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,29 +25,19 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
/**
|
||||
* Tables and data to convert MS932 to Unicode
|
||||
*
|
||||
* @author Limin Shi
|
||||
* @author Mark Son-Bell
|
||||
*/
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
public class ByteToCharMS932 extends ByteToCharMS932DB {
|
||||
ByteToCharJIS0201 bcJIS0201 = new ByteToCharJIS0201();
|
||||
public class ByteToCharMS932 extends ByteToCharDBCS_ASCII {
|
||||
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new MS932().newDecoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS932";
|
||||
}
|
||||
|
||||
protected char convSingleByte(int b) {
|
||||
// If the high bits are all off, it's ASCII == Unicode
|
||||
if ((b & 0xFF80) == 0) {
|
||||
return (char)b;
|
||||
}
|
||||
return bcJIS0201.getUnicode(b);
|
||||
public ByteToCharMS932() {
|
||||
super(dec);
|
||||
}
|
||||
|
||||
String prt(int i) {
|
||||
return Integer.toString(i,16);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,26 +25,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.MS936;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert MS936 to Unicode
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class ByteToCharMS936 extends ByteToCharDBCS_ASCII {
|
||||
|
||||
public class ByteToCharMS936 extends ByteToCharDoubleByte {
|
||||
|
||||
private final static MS936 nioCoder = new MS936();
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new MS936().newDecoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS936";
|
||||
}
|
||||
|
||||
public ByteToCharMS936() {
|
||||
super.index1 = nioCoder.getDecoderIndex1();
|
||||
super.index2 = nioCoder.getDecoderIndex2();
|
||||
start = 0x40;
|
||||
end = 0xFE;
|
||||
super(dec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,25 +26,19 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.MS949;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert MS949 to Unicode
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class ByteToCharMS949 extends ByteToCharDBCS_ASCII {
|
||||
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new MS949().newDecoder();
|
||||
|
||||
public class ByteToCharMS949 extends ByteToCharDoubleByte {
|
||||
private static final MS949 nioCoder = new MS949();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS949";
|
||||
}
|
||||
|
||||
public ByteToCharMS949() {
|
||||
super.index1 = nioCoder.getDecoderIndex1();
|
||||
super.index2 = nioCoder.getDecoderIndex2();
|
||||
start = 0x41;
|
||||
end = 0xFE;
|
||||
super(dec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,26 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.MS950;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert MS950 to Unicode
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class ByteToCharMS950 extends ByteToCharDBCS_ASCII {
|
||||
|
||||
public class ByteToCharMS950 extends ByteToCharDoubleByte {
|
||||
|
||||
private final static MS950 nioCoder = new MS950();
|
||||
private static DoubleByte.Decoder dec =
|
||||
(DoubleByte.Decoder)new MS950().newDecoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS950";
|
||||
}
|
||||
|
||||
public ByteToCharMS950() {
|
||||
super.index1 = nioCoder.getDecoderIndex1();
|
||||
super.index2 = nioCoder.getDecoderIndex2();
|
||||
start = 0x40;
|
||||
end = 0xFE;
|
||||
super(dec);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,6 @@ public class ByteToCharMS950_HKSCS extends ByteToCharHKSCS {
|
||||
|
||||
protected char getUnicode(int byte1, int byte2) {
|
||||
char c = super.getUnicode(byte1, byte2);
|
||||
return (c != REPLACE_CHAR) ? c : bcMS950.getUnicode(byte1, byte2);
|
||||
return (c != REPLACE_CHAR) ? c : bcMS950.decodeDouble(byte1, byte2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,24 +25,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.EUC_CN;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to EUC_CN
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class CharToByteEUC_CN extends CharToByteDBCS_ASCII {
|
||||
|
||||
public class CharToByteEUC_CN extends CharToByteDoubleByte {
|
||||
|
||||
private final static EUC_CN nioCoder = new EUC_CN();
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new EUC_CN().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "EUC_CN";
|
||||
}
|
||||
|
||||
public CharToByteEUC_CN() {
|
||||
super.index1 = nioCoder.getEncoderIndex1();
|
||||
super.index2 = nioCoder.getEncoderIndex2();
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,27 +23,20 @@
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.EUC_KR;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to EUC_KR
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class CharToByteEUC_KR extends CharToByteDBCS_ASCII {
|
||||
|
||||
public class CharToByteEUC_KR extends CharToByteDoubleByte {
|
||||
|
||||
private final static EUC_KR nioCoder = new EUC_KR();
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new EUC_KR().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "EUC_KR";
|
||||
}
|
||||
|
||||
public CharToByteEUC_KR() {
|
||||
super.index1 = nioCoder.getEncoderIndex1();
|
||||
super.index2 = nioCoder.getEncoderIndex2();
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,24 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.GBK;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to GBK
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class CharToByteGBK extends CharToByteDBCS_ASCII {
|
||||
|
||||
public class CharToByteGBK extends CharToByteDoubleByte {
|
||||
|
||||
private final static GBK nioCoder = new GBK();
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new GBK().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "GBK";
|
||||
}
|
||||
|
||||
public CharToByteGBK() {
|
||||
super.index1 = nioCoder.getEncoderIndex1();
|
||||
super.index2 = nioCoder.getEncoderIndex2();
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,24 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.Johab;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to Johab
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class CharToByteJohab extends CharToByteDBCS_ASCII {
|
||||
|
||||
public class CharToByteJohab extends CharToByteDoubleByte {
|
||||
|
||||
private final static Johab nioCoder = new Johab();
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new Johab().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "Johab";
|
||||
}
|
||||
|
||||
public CharToByteJohab() {
|
||||
super.index1 = nioCoder.getEncoderIndex1();
|
||||
super.index2 = nioCoder.getEncoderIndex2();
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,32 +25,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to MS932
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
public class CharToByteMS932 extends CharToByteMS932DB {
|
||||
CharToByteJIS0201 cbJIS0201 = new CharToByteJIS0201();
|
||||
public class CharToByteMS932 extends CharToByteDBCS_ASCII {
|
||||
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new MS932().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS932";
|
||||
}
|
||||
|
||||
protected int convSingleByte(char inputChar, byte[] outputByte) {
|
||||
byte b;
|
||||
|
||||
// \u0000 - \u007F map straight through
|
||||
if ((inputChar &0xFF80) == 0) {
|
||||
outputByte[0] = (byte)inputChar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((b = cbJIS0201.getNative(inputChar)) == 0)
|
||||
return 0;
|
||||
|
||||
outputByte[0] = b;
|
||||
return 1;
|
||||
public CharToByteMS932() {
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,24 +25,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.MS936;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to MS936
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class CharToByteMS936 extends CharToByteDBCS_ASCII {
|
||||
|
||||
public class CharToByteMS936 extends CharToByteDoubleByte {
|
||||
|
||||
private final static MS936 nioCoder = new MS936();
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new MS936().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS936";
|
||||
}
|
||||
|
||||
public CharToByteMS936() {
|
||||
super.index1 = nioCoder.getEncoderIndex1();
|
||||
super.index2 = nioCoder.getEncoderIndex2();
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,24 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.MS949;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to MS949
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class CharToByteMS949 extends CharToByteDBCS_ASCII {
|
||||
|
||||
public class CharToByteMS949 extends CharToByteDoubleByte {
|
||||
|
||||
private final static MS949 nioCoder = new MS949();
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new MS949().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS949";
|
||||
}
|
||||
|
||||
public CharToByteMS949() {
|
||||
super.index1 = nioCoder.getEncoderIndex1();
|
||||
super.index2 = nioCoder.getEncoderIndex2();
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,24 +26,18 @@
|
||||
|
||||
package sun.io;
|
||||
|
||||
import sun.nio.cs.ext.MS950;
|
||||
import sun.nio.cs.ext.*;
|
||||
|
||||
/**
|
||||
* Tables and data to convert Unicode to MS950
|
||||
*
|
||||
* @author ConverterGenerator tool
|
||||
*/
|
||||
public class CharToByteMS950 extends CharToByteDBCS_ASCII {
|
||||
|
||||
public class CharToByteMS950 extends CharToByteDoubleByte {
|
||||
|
||||
private final static MS950 nioCoder = new MS950();
|
||||
private static DoubleByte.Encoder enc =
|
||||
(DoubleByte.Encoder)new MS950().newEncoder();
|
||||
|
||||
public String getCharacterEncoding() {
|
||||
return "MS950";
|
||||
}
|
||||
|
||||
public CharToByteMS950() {
|
||||
super.index1 = nioCoder.getEncoderIndex1();
|
||||
super.index2 = nioCoder.getEncoderIndex2();
|
||||
super(enc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,6 @@ public class CharToByteMS950_HKSCS extends CharToByteHKSCS {
|
||||
|
||||
protected int getNative(char ch) {
|
||||
int r = super.getNative(ch);
|
||||
return (r != 0) ? r : cbMS950.getNative(ch);
|
||||
return (r != 0) ? r : cbMS950.encodeChar(ch);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,22 +26,15 @@
|
||||
package sun.management;
|
||||
|
||||
import java.lang.management.*;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import javax.management.DynamicMBean;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerFactory;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.NotificationEmitter;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.ObjectInstance;
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import javax.management.InstanceNotFoundException;
|
||||
import javax.management.MBeanRegistrationException;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import javax.management.RuntimeOperationsException;
|
||||
import javax.management.StandardEmitterMBean;
|
||||
import javax.management.StandardMBean;
|
||||
import java.nio.BufferPoolMXBean;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
@ -49,11 +42,6 @@ import sun.security.action.LoadLibraryAction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Iterator;
|
||||
import java.util.ListIterator;
|
||||
import com.sun.management.OSMBeanFactory;
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
|
||||
@ -68,7 +56,6 @@ public class ManagementFactoryHelper {
|
||||
|
||||
private static VMManagement jvm;
|
||||
|
||||
private static boolean mbeansCreated = false;
|
||||
private static ClassLoadingImpl classMBean = null;
|
||||
private static MemoryImpl memoryMBean = null;
|
||||
private static ThreadImpl threadMBean = null;
|
||||
@ -148,6 +135,58 @@ public class ManagementFactoryHelper {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<BufferPoolMXBean> getBufferPoolMXBeans() {
|
||||
List<BufferPoolMXBean> pools = new ArrayList<BufferPoolMXBean>(2);
|
||||
pools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
|
||||
.getDirectBufferPool()));
|
||||
pools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
|
||||
.getMappedBufferPool()));
|
||||
return pools;
|
||||
}
|
||||
|
||||
private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool";
|
||||
|
||||
/**
|
||||
* Creates management interface for the given buffer pool.
|
||||
*/
|
||||
private static BufferPoolMXBean
|
||||
createBufferPoolMXBean(final sun.misc.JavaNioAccess.BufferPool pool)
|
||||
{
|
||||
return new BufferPoolMXBean() {
|
||||
private volatile ObjectName objname; // created lazily
|
||||
@Override
|
||||
public ObjectName getObjectName() {
|
||||
ObjectName result = objname;
|
||||
if (result == null) {
|
||||
synchronized (this) {
|
||||
if (objname == null) {
|
||||
result = ObjectName.valueOf(BUFFER_POOL_MXBEAN_NAME +
|
||||
",name=" + pool.getName());
|
||||
objname = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return pool.getName();
|
||||
}
|
||||
@Override
|
||||
public long getCount() {
|
||||
return pool.getCount();
|
||||
}
|
||||
@Override
|
||||
public long getTotalCapacity() {
|
||||
return pool.getTotalCapacity();
|
||||
}
|
||||
@Override
|
||||
public long getMemoryUsed() {
|
||||
return pool.getMemoryUsed();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static HotSpotDiagnostic hsDiagMBean = null;
|
||||
private static HotspotRuntime hsRuntimeMBean = null;
|
||||
private static HotspotClassLoading hsClassMBean = null;
|
||||
@ -162,8 +201,6 @@ public class ManagementFactoryHelper {
|
||||
return hsDiagMBean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* This method is for testing only.
|
||||
*/
|
||||
|
||||
@ -25,8 +25,15 @@
|
||||
|
||||
package sun.misc;
|
||||
|
||||
import java.nio.BufferPoolMXBean;
|
||||
|
||||
public interface JavaNioAccess {
|
||||
BufferPoolMXBean getDirectBufferPoolMXBean();
|
||||
/**
|
||||
* Provides access to information on buffer usage.
|
||||
*/
|
||||
interface BufferPool {
|
||||
String getName();
|
||||
long getCount();
|
||||
long getTotalCapacity();
|
||||
long getMemoryUsed();
|
||||
}
|
||||
BufferPool getDirectBufferPool();
|
||||
}
|
||||
|
||||
@ -135,7 +135,9 @@ public class URLClassPath {
|
||||
* If the URL specified is null or is already in the list of
|
||||
* URLs, then invoking this method has no effect.
|
||||
*/
|
||||
public void addURL(URL url) {
|
||||
public synchronized void addURL(URL url) {
|
||||
if (closed)
|
||||
return;
|
||||
synchronized (urls) {
|
||||
if (url == null || path.contains(url))
|
||||
return;
|
||||
|
||||
171
jdk/src/share/classes/sun/net/www/http/HttpCapture.java
Normal file
171
jdk/src/share/classes/sun/net/www/http/HttpCapture.java
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.net.www.http;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import sun.net.NetProperties;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* Main class of the HTTP traffic capture tool.
|
||||
* Captures are triggered by the sun.net.http.captureRules system property.
|
||||
* If set, it should point to a file containing the capture rules.
|
||||
* Format for the file is simple:
|
||||
* - 1 rule per line
|
||||
* - Lines starting with a # are considered comments and ignored
|
||||
* - a rule is a pair of a regular expression and file pattern, separated by a comma
|
||||
* - The regular expression is applied to URLs, if it matches, the traffic for
|
||||
* that URL will be captured in the associated file.
|
||||
* - if the file name contains a '%d', then that sequence will be replaced by a
|
||||
* unique random number for each URL. This allow for multi-threaded captures
|
||||
* of URLs matching the same pattern.
|
||||
* - Rules are checked in sequence, in the same order as in the file, until a
|
||||
* match is found or the end of the list is reached.
|
||||
*
|
||||
* Examples of rules:
|
||||
* www\.sun\.com , sun%d.log
|
||||
* yahoo\.com\/.*asf , yahoo.log
|
||||
*
|
||||
* @author jccollet
|
||||
*/
|
||||
public class HttpCapture {
|
||||
private File file = null;
|
||||
private boolean incoming = true;
|
||||
private BufferedWriter out = null;
|
||||
private static boolean initialized = false;
|
||||
private static volatile ArrayList<Pattern> patterns = null;
|
||||
private static volatile ArrayList<String> capFiles = null;
|
||||
|
||||
private static synchronized void init() {
|
||||
initialized = true;
|
||||
String rulesFile = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
return NetProperties.get("sun.net.http.captureRules");
|
||||
}
|
||||
});
|
||||
if (rulesFile != null && !rulesFile.isEmpty()) {
|
||||
BufferedReader in;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(rulesFile));
|
||||
} catch (FileNotFoundException ex) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String line = in.readLine();
|
||||
while (line != null) {
|
||||
line = line.trim();
|
||||
if (!line.startsWith("#")) {
|
||||
// skip line if it's a comment
|
||||
String[] s = line.split(",");
|
||||
if (s.length == 2) {
|
||||
if (patterns == null) {
|
||||
patterns = new ArrayList<Pattern>();
|
||||
capFiles = new ArrayList<String>();
|
||||
}
|
||||
patterns.add(Pattern.compile(s[0].trim()));
|
||||
capFiles.add(s[1].trim());
|
||||
}
|
||||
}
|
||||
line = in.readLine();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
private HttpCapture(File f, java.net.URL url) {
|
||||
file = f;
|
||||
try {
|
||||
out = new BufferedWriter(new FileWriter(file, true));
|
||||
out.write("URL: " + url + "\n");
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(HttpCapture.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void sent(int c) throws IOException {
|
||||
if (incoming) {
|
||||
out.write("\n------>\n");
|
||||
incoming = false;
|
||||
out.flush();
|
||||
}
|
||||
out.write(c);
|
||||
}
|
||||
|
||||
public synchronized void received(int c) throws IOException {
|
||||
if (!incoming) {
|
||||
out.write("\n<------\n");
|
||||
incoming = true;
|
||||
out.flush();
|
||||
}
|
||||
out.write(c);
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
out.flush();
|
||||
}
|
||||
|
||||
public static HttpCapture getCapture(java.net.URL url) {
|
||||
if (!isInitialized()) {
|
||||
init();
|
||||
}
|
||||
if (patterns == null || patterns.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String s = url.toString();
|
||||
for (int i = 0; i < patterns.size(); i++) {
|
||||
Pattern p = patterns.get(i);
|
||||
if (p.matcher(s).find()) {
|
||||
String f = capFiles.get(i);
|
||||
File fi;
|
||||
if (f.indexOf("%d") >= 0) {
|
||||
java.util.Random rand = new java.util.Random();
|
||||
do {
|
||||
String f2 = f.replace("%d", Integer.toString(rand.nextInt()));
|
||||
fi = new File(f2);
|
||||
} while (fi.exists());
|
||||
} else {
|
||||
fi = new File(f);
|
||||
}
|
||||
return new HttpCapture(fi, url);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.net.www.http;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* A Simple FilterInputStream subclass to capture HTTP traffic.
|
||||
* Every byte read is also passed to the HttpCapture class.
|
||||
*
|
||||
* @author jccollet
|
||||
*/
|
||||
public class HttpCaptureInputStream extends FilterInputStream {
|
||||
private HttpCapture capture = null;
|
||||
|
||||
public HttpCaptureInputStream(InputStream in, HttpCapture cap) {
|
||||
super(in);
|
||||
capture = cap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int i = super.read();
|
||||
capture.received(i);
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
capture.flush();
|
||||
} catch (IOException iOException) {
|
||||
}
|
||||
super.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
int ret = super.read(b);
|
||||
for (int i = 0; i < ret; i++) {
|
||||
capture.received(b[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
int ret = super.read(b, off, len);
|
||||
for (int i = 0; i < ret; i++) {
|
||||
capture.received(b[off+i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.net.www.http;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* A Simple FilterOutputStream subclass to capture HTTP traffic.
|
||||
* Every byte written is also passed to the HttpCapture class.
|
||||
*
|
||||
* @author jccollet
|
||||
*/
|
||||
public class HttpCaptureOutputStream extends FilterOutputStream {
|
||||
private HttpCapture capture = null;
|
||||
|
||||
public HttpCaptureOutputStream(OutputStream out, HttpCapture cap) {
|
||||
super(out);
|
||||
capture = cap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
capture.sent(b);
|
||||
out.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] ba) throws IOException {
|
||||
for (byte b : ba) {
|
||||
capture.sent(b);
|
||||
}
|
||||
out.write(ba);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
for (int i = off; i < len; i++) {
|
||||
capture.sent(b[i]);
|
||||
}
|
||||
out.write(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
try {
|
||||
capture.flush();
|
||||
} catch (IOException iOException) {
|
||||
}
|
||||
super.flush();
|
||||
}
|
||||
}
|
||||
@ -27,6 +27,9 @@ package sun.net.www.http;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import sun.net.NetworkClient;
|
||||
import sun.net.ProgressSource;
|
||||
import sun.net.www.MessageHeader;
|
||||
@ -34,7 +37,6 @@ import sun.net.www.HeaderParser;
|
||||
import sun.net.www.MeteredStream;
|
||||
import sun.net.www.ParseUtil;
|
||||
import sun.net.www.protocol.http.HttpURLConnection;
|
||||
import sun.misc.RegexpPool;
|
||||
|
||||
/**
|
||||
* @author Herb Jellinek
|
||||
@ -64,6 +66,10 @@ public class HttpClient extends NetworkClient {
|
||||
/** Default port number for http daemons. REMIND: make these private */
|
||||
static final int httpPortNumber = 80;
|
||||
|
||||
// Use same logger as HttpURLConnection since we want to combine both event
|
||||
// streams into one single HTTP log
|
||||
private static Logger logger = Logger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
|
||||
|
||||
/** return default port number (subclasses may override) */
|
||||
protected int getDefaultPort () { return httpPortNumber; }
|
||||
|
||||
@ -75,30 +81,6 @@ public class HttpClient extends NetworkClient {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* The following three data members are left in for binary */
|
||||
/* backwards-compatibility. Unfortunately, HotJava sets them directly */
|
||||
/* when it wants to change the settings. The new design has us not */
|
||||
/* cache these, so this is unnecessary, but eliminating the data members */
|
||||
/* would break HJB 1.1 under JDK 1.2. */
|
||||
/* */
|
||||
/* These data members are not used, and their values are meaningless. */
|
||||
/* REMIND: Take them out for JDK 2.0! */
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
// public static String proxyHost = null;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
// public static int proxyPort = 80;
|
||||
|
||||
/* instance-specific proxy fields override the static fields if set.
|
||||
* Used by FTP. These are set to the true proxy host/port if
|
||||
* usingProxy is true.
|
||||
*/
|
||||
// private String instProxy = null;
|
||||
// private int instProxyPort = -1;
|
||||
|
||||
/* All proxying (generic as well as instance-specific) may be
|
||||
* disabled through use of this flag
|
||||
*/
|
||||
@ -141,6 +123,9 @@ public class HttpClient extends NetworkClient {
|
||||
/* if set, the client will be reused and must not be put in cache */
|
||||
public boolean reuse = false;
|
||||
|
||||
// Traffic capture tool, if configured. See HttpCapture class for info
|
||||
private HttpCapture capture = null;
|
||||
|
||||
/**
|
||||
* A NOP method kept for backwards binary compatibility
|
||||
* @deprecated -- system properties are no longer cached.
|
||||
@ -226,6 +211,7 @@ public class HttpClient extends NetworkClient {
|
||||
}
|
||||
});
|
||||
|
||||
capture = HttpCapture.getCapture(url);
|
||||
openServer();
|
||||
}
|
||||
|
||||
@ -300,8 +286,10 @@ public class HttpClient extends NetworkClient {
|
||||
// KeepAliveTimeout will get reset. We simply close the connection.
|
||||
// This should be fine as it is very rare that a connection
|
||||
// to the same host will not use the same proxy.
|
||||
ret.inCache = false;
|
||||
ret.closeServer();
|
||||
synchronized(ret) {
|
||||
ret.inCache = false;
|
||||
ret.closeServer();
|
||||
}
|
||||
ret = null;
|
||||
}
|
||||
}
|
||||
@ -369,7 +357,7 @@ public class HttpClient extends NetworkClient {
|
||||
kac.put(url, null, this);
|
||||
}
|
||||
|
||||
protected boolean isInKeepAliveCache() {
|
||||
protected synchronized boolean isInKeepAliveCache() {
|
||||
return inCache;
|
||||
}
|
||||
|
||||
@ -389,11 +377,16 @@ public class HttpClient extends NetworkClient {
|
||||
* method parseHTTP(). That's why this method is overidden from the
|
||||
* superclass.
|
||||
*/
|
||||
@Override
|
||||
public void openServer(String server, int port) throws IOException {
|
||||
serverSocket = doConnect(server, port);
|
||||
try {
|
||||
OutputStream out = serverSocket.getOutputStream();
|
||||
if (capture != null) {
|
||||
out = new HttpCaptureOutputStream(out, capture);
|
||||
}
|
||||
serverOutput = new PrintStream(
|
||||
new BufferedOutputStream(serverSocket.getOutputStream()),
|
||||
new BufferedOutputStream(out),
|
||||
false, encoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new InternalError(encoding+" encoding not found");
|
||||
@ -412,7 +405,7 @@ public class HttpClient extends NetworkClient {
|
||||
/*
|
||||
* Returns true if this httpclient is from cache
|
||||
*/
|
||||
public boolean isCachedConnection() {
|
||||
public synchronized boolean isCachedConnection() {
|
||||
return cachedHttpClient;
|
||||
}
|
||||
|
||||
@ -457,26 +450,6 @@ public class HttpClient extends NetworkClient {
|
||||
super.openServer(proxyHost, proxyPort);
|
||||
}
|
||||
|
||||
/*
|
||||
* call super.openServer in a privileged block
|
||||
*/
|
||||
private synchronized void privilegedSuperOpenServer(final String proxyHost,
|
||||
final int proxyPort)
|
||||
throws IOException
|
||||
{
|
||||
try {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction<Void>() {
|
||||
public Void run() throws IOException {
|
||||
superOpenServer(proxyHost, proxyPort);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (java.security.PrivilegedActionException pae) {
|
||||
throw (IOException) pae.getException();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
protected synchronized void openServer() throws IOException {
|
||||
@ -490,8 +463,6 @@ public class HttpClient extends NetworkClient {
|
||||
return;
|
||||
}
|
||||
|
||||
String urlHost = url.getHost().toLowerCase();
|
||||
|
||||
if (url.getProtocol().equals("http") ||
|
||||
url.getProtocol().equals("https") ) {
|
||||
|
||||
@ -595,6 +566,9 @@ public class HttpClient extends NetworkClient {
|
||||
|
||||
try {
|
||||
serverInput = serverSocket.getInputStream();
|
||||
if (capture != null) {
|
||||
serverInput = new HttpCaptureInputStream(serverInput, capture);
|
||||
}
|
||||
serverInput = new BufferedInputStream(serverInput);
|
||||
return (parseHTTPHeader(responses, pi, httpuc));
|
||||
} catch (SocketTimeoutException stex) {
|
||||
@ -686,7 +660,7 @@ public class HttpClient extends NetworkClient {
|
||||
if (keep == null) {
|
||||
keep = responses.findValue("Connection");
|
||||
}
|
||||
if (keep != null && keep.toLowerCase().equals("keep-alive")) {
|
||||
if (keep != null && keep.toLowerCase(Locale.US).equals("keep-alive")) {
|
||||
/* some servers, notably Apache1.1, send something like:
|
||||
* "Keep-Alive: timeout=15, max=1" which we should respect.
|
||||
*/
|
||||
@ -767,10 +741,7 @@ public class HttpClient extends NetworkClient {
|
||||
* the HTTP method and response code indicate there will be
|
||||
* no entity body to parse.
|
||||
*/
|
||||
String te = null;
|
||||
try {
|
||||
te = responses.findValue("Transfer-Encoding");
|
||||
} catch (Exception e) {}
|
||||
String te = responses.findValue("Transfer-Encoding");
|
||||
if (te != null && te.equalsIgnoreCase("chunked")) {
|
||||
serverInput = new ChunkedInputStream(serverInput, this, responses);
|
||||
|
||||
@ -794,10 +765,14 @@ public class HttpClient extends NetworkClient {
|
||||
* 2. "Not-Modified" or "No-Content" responses - RFC 2616 states that
|
||||
* 204 or 304 response must not include a message body.
|
||||
*/
|
||||
try {
|
||||
cl = Long.parseLong(responses.findValue("content-length"));
|
||||
} catch (Exception e) {}
|
||||
|
||||
String cls = responses.findValue("content-length");
|
||||
if (cls != null) {
|
||||
try {
|
||||
cl = Long.parseLong(cls);
|
||||
} catch (NumberFormatException e) {
|
||||
cl = -1;
|
||||
}
|
||||
}
|
||||
String requestLine = requests.getKey(0);
|
||||
|
||||
if ((requestLine != null &&
|
||||
@ -835,6 +810,9 @@ public class HttpClient extends NetworkClient {
|
||||
|
||||
if (isKeepingAlive()) {
|
||||
// Wrap KeepAliveStream if keep alive is enabled.
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.finest("KeepAlive stream used: " + url);
|
||||
}
|
||||
serverInput = new KeepAliveStream(serverInput, pi, cl, this);
|
||||
failedOnce = false;
|
||||
}
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package sun.net.www.protocol.http;
|
||||
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
* A Formatter to make the HTTP logs a bit more palatable to the developer
|
||||
* looking at them. The idea is to present the HTTP events in such a way that
|
||||
* commands and headers are easily spotted (i.e. on separate lines).
|
||||
* @author jccollet
|
||||
*/
|
||||
public class HttpLogFormatter extends java.util.logging.SimpleFormatter {
|
||||
// Pattern for MessageHeader data. Mostly pairs within curly brackets
|
||||
private static volatile Pattern pattern = null;
|
||||
// Pattern for Cookies
|
||||
private static volatile Pattern cpattern = null;
|
||||
|
||||
public HttpLogFormatter() {
|
||||
if (pattern == null) {
|
||||
pattern = Pattern.compile("\\{[^\\}]*\\}");
|
||||
cpattern = Pattern.compile("[^,\\] ]{2,}");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
if (!"sun.net.www.protocol.http.HttpURLConnection".equalsIgnoreCase(record.getSourceClassName())
|
||||
&& !"sun.net.www.http.HttpClient".equalsIgnoreCase(record.getSourceClassName())) {
|
||||
// Don't change format for stuff that doesn't concern us
|
||||
return super.format(record);
|
||||
}
|
||||
String src = record.getMessage();
|
||||
StringBuilder buf = new StringBuilder("HTTP: ");
|
||||
if (src.startsWith("sun.net.www.MessageHeader@")) {
|
||||
// MessageHeader logs are composed of pairs within curly brackets
|
||||
// Let's extract them to make it more readable. That way we get one
|
||||
// header pair (name, value) per line. A lot easier to read.
|
||||
Matcher match = pattern.matcher(src);
|
||||
while (match.find()) {
|
||||
int i = match.start();
|
||||
int j = match.end();
|
||||
String s = src.substring(i + 1, j - 1);
|
||||
if (s.startsWith("null: ")) {
|
||||
s = s.substring(6);
|
||||
}
|
||||
if (s.endsWith(": null")) {
|
||||
s = s.substring(0, s.length() - 6);
|
||||
}
|
||||
buf.append("\t").append(s).append("\n");
|
||||
}
|
||||
} else if (src.startsWith("Cookies retrieved: {")) {
|
||||
// This comes from the Cookie handler, let's clean up the format a bit
|
||||
String s = src.substring(20);
|
||||
buf.append("Cookies from handler:\n");
|
||||
while (s.length() >= 7) {
|
||||
if (s.startsWith("Cookie=[")) {
|
||||
String s2 = s.substring(8);
|
||||
int c = s2.indexOf("Cookie2=[");
|
||||
if (c > 0) {
|
||||
s2 = s2.substring(0, c-1);
|
||||
s = s2.substring(c);
|
||||
} else {
|
||||
s = "";
|
||||
}
|
||||
if (s2.length() < 4) {
|
||||
continue;
|
||||
}
|
||||
Matcher m = cpattern.matcher(s2);
|
||||
while (m.find()) {
|
||||
int i = m.start();
|
||||
int j = m.end();
|
||||
if (i >= 0) {
|
||||
String cookie = s2.substring(i + 1, j > 0 ? j - 1 : s2.length() - 1);
|
||||
buf.append("\t").append(cookie).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (s.startsWith("Cookie2=[")) {
|
||||
String s2 = s.substring(9);
|
||||
int c = s2.indexOf("Cookie=[");
|
||||
if (c > 0) {
|
||||
s2 = s2.substring(0, c-1);
|
||||
s = s2.substring(c);
|
||||
} else {
|
||||
s = "";
|
||||
}
|
||||
Matcher m = cpattern.matcher(s2);
|
||||
while (m.find()) {
|
||||
int i = m.start();
|
||||
int j = m.end();
|
||||
if (i >= 0) {
|
||||
String cookie = s2.substring(i+1, j > 0 ? j-1 : s2.length() - 1);
|
||||
buf.append("\t").append(cookie).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Anything else we let as is.
|
||||
buf.append(src).append("\n");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@ -237,6 +237,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
/* try auth without calling Authenticator */
|
||||
private boolean tryTransparentNTLMServer = NTLMAuthentication.supportsTransparentAuth();
|
||||
private boolean tryTransparentNTLMProxy = NTLMAuthentication.supportsTransparentAuth();
|
||||
/* Used by Windows specific code */
|
||||
Object authObj;
|
||||
|
||||
/* Set if the user is manually setting the Authorization or Proxy-Authorization headers */
|
||||
@ -303,9 +304,16 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
return java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<PasswordAuthentication>() {
|
||||
public PasswordAuthentication run() {
|
||||
return Authenticator.requestPasswordAuthentication(
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.finest("Requesting Authentication: host =" + host + " url = " + url);
|
||||
}
|
||||
PasswordAuthentication pass = Authenticator.requestPasswordAuthentication(
|
||||
host, addr, port, protocol,
|
||||
prompt, scheme, url, authType);
|
||||
if (pass != null && logger.isLoggable(Level.FINEST)) {
|
||||
logger.finest("Authentication returned: " + pass.toString());
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -458,7 +466,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
|
||||
setRequests=true;
|
||||
}
|
||||
if(logger.isLoggable(Level.FINEST)) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(requests.toString());
|
||||
}
|
||||
http.writeRequests(requests, poster);
|
||||
@ -602,7 +610,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
{
|
||||
boolean redir;
|
||||
int redirects = 0;
|
||||
InputStream in = null;
|
||||
InputStream in;
|
||||
|
||||
do {
|
||||
if (c instanceof HttpURLConnection) {
|
||||
@ -715,6 +723,12 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
&& !(cachedResponse instanceof SecureCacheResponse)) {
|
||||
cachedResponse = null;
|
||||
}
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.finest("Cache Request for " + uri + " / " + getRequestMethod());
|
||||
if (cachedResponse != null) {
|
||||
logger.finest("From cache: "+cachedResponse.toString());
|
||||
}
|
||||
}
|
||||
if (cachedResponse != null) {
|
||||
cachedHeaders = mapToMessageHeader(cachedResponse.getHeaders());
|
||||
cachedInputStream = cachedResponse.getBody();
|
||||
@ -750,10 +764,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
return ProxySelector.getDefault();
|
||||
}
|
||||
});
|
||||
Proxy p = null;
|
||||
if (sel != null) {
|
||||
URI uri = sun.net.www.ParseUtil.toURI(url);
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.finest("ProxySelector Request for " + uri);
|
||||
}
|
||||
Iterator<Proxy> it = sel.select(uri).iterator();
|
||||
Proxy p;
|
||||
while (it.hasNext()) {
|
||||
p = it.next();
|
||||
try {
|
||||
@ -766,6 +783,11 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
http = getNewHttpClient(url, p, connectTimeout, false);
|
||||
http.setReadTimeout(readTimeout);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
if (p != null) {
|
||||
logger.finest("Proxy used: " + p.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
} catch (IOException ioex) {
|
||||
if (p != Proxy.NO_PROXY) {
|
||||
@ -993,10 +1015,16 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
|
||||
URI uri = ParseUtil.toURI(url);
|
||||
if (uri != null) {
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.finest("CookieHandler request for " + uri);
|
||||
}
|
||||
Map<String, List<String>> cookies
|
||||
= cookieHandler.get(
|
||||
uri, requests.getHeaders(EXCLUDE_HEADERS));
|
||||
if (!cookies.isEmpty()) {
|
||||
if (logger.isLoggable(Level.FINEST)) {
|
||||
logger.finest("Cookies retrieved: " + cookies.toString());
|
||||
}
|
||||
for (Map.Entry<String, List<String>> entry :
|
||||
cookies.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
@ -1126,7 +1154,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
writeRequests();
|
||||
}
|
||||
http.parseHTTP(responses, pi, this);
|
||||
if(logger.isLoggable(Level.FINEST)) {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(responses.toString());
|
||||
}
|
||||
inputStream = http.getInputStream();
|
||||
@ -1571,7 +1599,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
http.parseHTTP(responses, null, this);
|
||||
|
||||
/* Log the response to the CONNECT */
|
||||
logger.fine(responses.toString());
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(responses.toString());
|
||||
}
|
||||
|
||||
statusLine = responses.getValue(0);
|
||||
StringTokenizer st = new StringTokenizer(statusLine);
|
||||
@ -1617,8 +1647,6 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
reset ();
|
||||
if (!proxyAuthentication.setHeaders(this,
|
||||
authhdr.headerParser(), raw)) {
|
||||
proxyHost = http.getProxyHostUsed();
|
||||
proxyPort = http.getProxyPortUsed();
|
||||
disconnectInternal();
|
||||
throw new IOException ("Authentication failure");
|
||||
}
|
||||
@ -1699,7 +1727,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
setPreemptiveProxyAuthentication(requests);
|
||||
|
||||
/* Log the CONNECT request */
|
||||
logger.fine(requests.toString());
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(requests.toString());
|
||||
}
|
||||
|
||||
http.writeRequests(requests, null);
|
||||
// remove CONNECT header
|
||||
@ -1842,6 +1872,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logger.isLoggable(Level.FINER)) {
|
||||
logger.finer("Proxy Authentication for " + authhdr.toString() +" returned " + ret.toString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1896,21 +1929,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
}
|
||||
if (ret == null) {
|
||||
if (schemeID == NegotiateAuthentication.KERBEROS_AUTH) {
|
||||
URL url1;
|
||||
try {
|
||||
url1 = new URL (url, "/"); /* truncate the path */
|
||||
} catch (Exception e) {
|
||||
url1 = url;
|
||||
}
|
||||
ret = new NegotiateAuthentication(new HttpCallerInfo(authhdr.getHttpCallerInfo(), "Kerberos"));
|
||||
}
|
||||
if (schemeID == NegotiateAuthentication.NEGOTIATE_AUTH) {
|
||||
URL url1;
|
||||
try {
|
||||
url1 = new URL (url, "/"); /* truncate the path */
|
||||
} catch (Exception e) {
|
||||
url1 = url;
|
||||
}
|
||||
ret = new NegotiateAuthentication(new HttpCallerInfo(authhdr.getHttpCallerInfo(), "Negotiate"));
|
||||
}
|
||||
if (schemeID == BasicAuthentication.BASIC_AUTH) {
|
||||
@ -1981,6 +2002,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logger.isLoggable(Level.FINER)) {
|
||||
logger.finer("Server Authentication for " + authhdr.toString() +" returned " + ret.toString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2054,6 +2078,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
if (streaming()) {
|
||||
throw new HttpRetryException (RETRY_MSG3, stat, loc);
|
||||
}
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine("Redirected from " + url + " to " + locUrl);
|
||||
}
|
||||
|
||||
// clear out old response headers!!!!
|
||||
responses = new MessageHeader();
|
||||
@ -2158,11 +2185,17 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
/* raw stream, which will block on read, so only read
|
||||
* the expected number of bytes, probably 0
|
||||
*/
|
||||
int cl = 0, n=0;
|
||||
try {
|
||||
cl = Integer.parseInt (responses.findValue ("Content-Length"));
|
||||
} catch (Exception e) {}
|
||||
for (int i=0; i<cl; ) {
|
||||
long cl = 0;
|
||||
int n = 0;
|
||||
String cls = responses.findValue ("Content-Length");
|
||||
if (cls != null) {
|
||||
try {
|
||||
cl = Long.parseLong (cls);
|
||||
} catch (NumberFormatException e) {
|
||||
cl = 0;
|
||||
}
|
||||
}
|
||||
for (long i=0; i<cl; ) {
|
||||
if ((n = is.read (cdata)) == -1) {
|
||||
break;
|
||||
} else {
|
||||
@ -2509,12 +2542,6 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
||||
return readTimeout < 0 ? 0 : readTimeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
// this should do nothing. The stream finalizer will close
|
||||
// the fd
|
||||
}
|
||||
|
||||
String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
@ -29,13 +29,10 @@ import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.BufferPoolMXBean;
|
||||
import java.nio.channels.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.security.AccessController;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import sun.misc.Cleaner;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
@ -805,47 +802,28 @@ public class FileChannelImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the management interface for mapped buffers
|
||||
* Invoked by sun.management.ManagementFactoryHelper to create the management
|
||||
* interface for mapped buffers.
|
||||
*/
|
||||
public static BufferPoolMXBean getMappedBufferPoolMXBean() {
|
||||
return LazyInitialization.mappedBufferPoolMXBean;
|
||||
}
|
||||
|
||||
// Lazy initialization of management interface
|
||||
private static class LazyInitialization {
|
||||
static final BufferPoolMXBean mappedBufferPoolMXBean = mappedBufferPoolMXBean();
|
||||
|
||||
private static BufferPoolMXBean mappedBufferPoolMXBean() {
|
||||
final String pool = "mapped";
|
||||
final ObjectName obj;
|
||||
try {
|
||||
obj = new ObjectName("java.nio:type=BufferPool,name=" + pool);
|
||||
} catch (MalformedObjectNameException x) {
|
||||
throw new AssertionError(x);
|
||||
public static sun.misc.JavaNioAccess.BufferPool getMappedBufferPool() {
|
||||
return new sun.misc.JavaNioAccess.BufferPool() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "mapped";
|
||||
}
|
||||
return new BufferPoolMXBean() {
|
||||
@Override
|
||||
public ObjectName getObjectName() {
|
||||
return obj;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return pool;
|
||||
}
|
||||
@Override
|
||||
public long getCount() {
|
||||
return Unmapper.count;
|
||||
}
|
||||
@Override
|
||||
public long getTotalCapacity() {
|
||||
return Unmapper.totalCapacity;
|
||||
}
|
||||
@Override
|
||||
public long getMemoryUsed() {
|
||||
return Unmapper.totalSize;
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public long getCount() {
|
||||
return Unmapper.count;
|
||||
}
|
||||
@Override
|
||||
public long getTotalCapacity() {
|
||||
return Unmapper.totalCapacity;
|
||||
}
|
||||
@Override
|
||||
public long getMemoryUsed() {
|
||||
return Unmapper.totalSize;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// -- Locks --
|
||||
|
||||
@ -142,7 +142,7 @@ class ISO_8859_1
|
||||
}
|
||||
|
||||
public boolean isLegalReplacement(byte[] repl) {
|
||||
return (repl.length == 1); // we accept any byte value
|
||||
return true; // we accept any byte value
|
||||
}
|
||||
|
||||
private final Surrogate.Parser sgp = new Surrogate.Parser();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user