/* * Copyright (c) 2008, 2022, Oracle and/or its affiliates. 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. * * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
publicstaticvoid main(String args[]) throws Throwable {
System.out.printf("sun.jnu.encoding=%s, file.encoding=%s%n",
System.getProperty("file.encoding"),
System.getProperty("sun.jnu.encoding")); // English
test("TestDir_apple", // test dir "dir_macosx", // dir "file_macosx"); // file
// Japanese composite character
test("TestDir_\u30c8\u30a4\u30e4\u30cb\u30ca\u30eb/", "dir_\u30a4\u30c1\u30b4\u306e\u30b1\u30fc\u30ad", "file_\u30a4\u30c1\u30b4\u306e\u30b1\u30fc\u30ad");
////////////////////////////////////////////////////////////// if (!Files.isDirectory(dpath) || !Files.isDirectory(dpath_nfd)) { thrownew RuntimeException("Files.isDirectory(...) failed");
}
////////////////////////////////////////////////////////////// // write out with nfd, read in with nfc + case
Files.write(fpath_nfd, newbyte[] { 'n', 'f', 'd'});
System.out.println(" read in with nfc (from nfd):" + new String(Files.readAllBytes(fpath_nfc)));
// check attrs with nfc + case
Set<PosixFilePermission> pfp = Files.getPosixFilePermissions(fpath_nfd); if (!equal(pfp, Files.getPosixFilePermissions(fpath_nfc)) ) { thrownew RuntimeException("Files.getPosixfilePermission(...) failed");
}
Files.delete(fpath_nfd);
// write out with nfc, read in with nfd + case
Files.write(fpath_nfc, newbyte[] { 'n', 'f', 'c'});
System.out.println(" read in with nfd (from nfc):" + new String(Files.readAllBytes(fpath_nfd)));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.