Java gets the default character set-knowledge grooming

Source: Internet
Author: User

1. Directly on the code

import java.nio.charset.charset;/** *  Gets the default character set for the current virtual machine  charset.defaultcharset ()   or   System.getproperty ("file.encoding")  * charset.defaultcharset () The underlying code is also by calling  system.getproperty (" File.encoding ")   implement &NBSP;*&NBSP;&LT;P&GT;&NBSP;*&NBSP;1. Default encoding only by passing  jvm  parameters (the JVM is active at startup and cannot be changed)  ==  subsequent changes invalid &NBSP;&LT;BR/&GT;&NBSP;*&NBSP;2. This system property is correctly called: from the Java.nio.charset.Charset.defaultCharset () comment  <br/> *  English:the default charset of this java virtual  machine <br/> *  Chinese: The default  charset <br/> * 3 for this  Java  virtual machine. The JVM parameters are specified in the following way: Java -dfile.encoding=xxx * 4. If you are running the main method in Eclipse, set see Figure 2 in this article.  * </p> *  *  @author  yuxiangtong * */public class  test {    public static void main (String[] args)  {         string&nBsp;encoding = system.getproperty ("file.encoding");         System.out.println ("FILE.ENCODING&NBSP;:"  + encoding); // utf-8         system.out.println (                  "Default  charset&nbsp for this  Java  virtual machine;:"  + charset.defaultcharset (). Name ()); // utf-8        /*  attempt to reset  file.encoding  */        encoding = system.setproperty ("file.encoding ", " GBK ");        /*  reset failed, remains the default utf-8 */   &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;SYSTEM.OUT.PRINTLN (encoding); // utf-8         /*  try to get test properties  */         System.out.println (System.getproperTy ("TestKey"));  // null        system.setproperty ("TestKey"),   "Zhang San");         system.out.println (System.getproperty ("TestKey"));  //  Zhang San         system.out.println ("Zhang San". GetBytes (). length);  // 6    }}


2. Figure 2 Below

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8B/37/wKioL1hHcfKTbHMFAADDoTjAXb0750.png "title=" Run the test. png "alt=" Wkiol1hhcfktbhmfaaddotjaxb0750.png "/>


3.DOS command-line prompt message:

c:\users>java -versionjava version  "1.8.0_65" java (TM)  se runtime environment   (BUILD&NBSP;1.8.0_65-B17) java hotspot (TM)  64-Bit Server VM  (build 25.65- B01, mixed mode) C:\users>java usage:  java [-options] class [args ...]             (Executive Class)     or   java  [-options] -jar jarfile [args ...]             (execution  jar  file) where options include:     -d32           using the  32  bit data Model   (if available)     -d64           using the  64  bit data model   (if available)     -server        select   "Server" &NBSP;VM                    default  VM  is  server.    -cp < directory and  zip/jar  Class search paths for files >    -classpath < directories and  zip/jar  classes of files >                    with  ;  separate directories,  JAR  Archives                     and  ZIP  archive list,  is used to search for class files.     -D< name >=< value >                    Set System Properties     -verbose:[class|gc|jni]                    Enable verbose output     -version       output product version and exit     -version: < values >                   warning:  This feature is obsolete,  will be in                     removed in future releases.                    The specified version is required to run     -showversion   output the product version and Continue     - jre-restrict-search | -no-jre-restrict-search                    warning:  This feature is obsolete,  will be in                     removed in future releases.                    Include/exclude user-specific  JRE    -? -help       output this Help message in version search      -X             output non-standard options help     -ea[:<packagename>...|:<classname>]    -enableassertions[: <packagename>...|:<classname>]                    enable assertions by a specified granularity     -da[:<packagename>...|:< classname>]    -disableassertions[:<packagename>...|:<classname>]                    Disables assertions with the specified granularity     -esa | -enablesystemassertions                    Enable System Assertion     - dsa | -disablesystemassertions                    Disable system assertion     -agentlib:<libname>[=< options;]                    loading the native agent library  <libname>,  for example  -agentlib:hprof                    See also  -agentlib:jdwp=help  and  -agentlib:hprof=help     -agentpath:<pathname>[=< Options >]                    load a native agent library by full pathname     -javaagent:<jarpath>[= < options >]                    load  Java  programming language proxy,  see  java.lang.instrument    -splash:< imagepath>                    Display the splash screen with the specified image for more information,  see  http://www.oracle.com/technetwork/java/javase/documentation/index.html.


This article is from my Tech blog blog, so be sure to keep this source http://programmer.blog.51cto.com/2859493/1880248

Java gets the default character set-knowledge grooming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.