< prev index next >

src/java.base/share/classes/sun/nio/fs/Util.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.fs;
  27 
  28 import java.util.*;
  29 import java.nio.file.*;
  30 import java.nio.charset.Charset;
  31 import java.security.*;
  32 import sun.security.action.*;
  33 
  34 /**
  35  * Utility methods
  36  */
  37 
  38 class Util {
  39     private Util() { }
  40 
  41     private static final Charset jnuEncoding = Charset.forName(
  42         AccessController.doPrivileged(new GetPropertyAction("sun.jnu.encoding")));
  43 
  44     /**
  45      * Returns {@code Charset} corresponding to the sun.jnu.encoding property
  46      */
  47     static Charset jnuEncoding() {
  48         return jnuEncoding;
  49     }
  50 
  51     /**
  52      * Encodes the given String into a sequence of bytes using the {@code Charset}
  53      * specified by the sun.jnu.encoding property.
  54      */
  55     static byte[] toBytes(String s) {
  56         return s.getBytes(jnuEncoding);
  57     }
  58 
  59     /**
  60      * Constructs a new String by decoding the specified array of bytes using the
  61      * {@code Charset} specified by the sun.jnu.encoding property.
  62      */




  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.fs;
  27 
  28 import java.util.*;
  29 import java.nio.file.*;
  30 import java.nio.charset.Charset;
  31 import sun.security.action.GetPropertyAction;

  32 
  33 /**
  34  * Utility methods
  35  */
  36 
  37 class Util {
  38     private Util() { }
  39 
  40     private static final Charset jnuEncoding = Charset.forName(
  41         GetPropertyAction.getProperty("sun.jnu.encoding"));
  42 
  43     /**
  44      * Returns {@code Charset} corresponding to the sun.jnu.encoding property
  45      */
  46     static Charset jnuEncoding() {
  47         return jnuEncoding;
  48     }
  49 
  50     /**
  51      * Encodes the given String into a sequence of bytes using the {@code Charset}
  52      * specified by the sun.jnu.encoding property.
  53      */
  54     static byte[] toBytes(String s) {
  55         return s.getBytes(jnuEncoding);
  56     }
  57 
  58     /**
  59      * Constructs a new String by decoding the specified array of bytes using the
  60      * {@code Charset} specified by the sun.jnu.encoding property.
  61      */


< prev index next >