MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / main

Method main

day21/code/day21_IO/src/cn/itcast_05/StringDemo.java:18–37  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

16 */
17public class StringDemo {
18 public static void main(String[] args) throws UnsupportedEncodingException {
19 String s = "���";
20
21 // public byte[] getBytes()
22 // byte[] bys = s.getBytes();
23 // [-60, -29, -70, -61]
24 // public byte[] getBytes(String charsetName)
25 byte[] bys = s.getBytes("GBK");
26 // [-60, -29, -70, -61]
27 // byte[] bys = s.getBytes("UTF-8");
28 // [-28, -67, -96, -27, -91, -67]
29 System.out.println(Arrays.toString(bys));
30
31 // String(byte[] bytes)
32 // String ss = new String(bys);
33 // public String(byte[] bytes, String charsetName)
34 String ss = new String(bys, "GBK");
35 // String ss = new String(bys, "UTF-8");
36 System.out.println(ss);
37 }
38}

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected