16进制转字符串
private static String hexStringToString(String s) { if (s == null || s.equals("")) { return null; } s = s.replace(" ", ""); s = s.replace("0x", ""); byte[] baKeyword = new byte[s.length() / 2]; for (int i = 0; i < baKeyword.length; i++) { baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); } return new String(baKeyword, StandardCharsets.UTF_8); }
文件复制
File file = getFile(cfg);FileUtils.copyFile(file, cfg.getResponse().getOutputStream());int n;FileInputStream fis = new FileInputStream(file);byte[] buffer = new byte[4096];for (; -1 != (n = fis.read(buffer)); ) { cfg.getResponse().getOutputStream().write(buffer, 0, n);}file.deleteOnExit();
根据多个字符分割字符串
String s = "123,45;iops,123;,234"; String[] arr = s.split("[,,;;]"); for (String a : arr) { System.out.print(a + " %%");}