java中微信支付其一

2024-11-11 17:26:52

1、public class FileUtil { public static void mkdirs(String dir){ if(StringUtils.isEmpty(dir)){ return; } File file = new File(dir); if(file.isDirectory()){ return; } else { file.mkdirs(); } }}fileUtil主要是用来判断是否存在文件夹,如果不存在则创建文件

java中微信支付其一

3、 conn.setDoOutput(true); conn.setConnectTimeout(CONNECT_TIMEOUT); conn.setReadTimeout(CONNECT_TIMEOUT); if(contentType != null) conn.setRequestProperty("content-type", contentType); OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), DEFAULT_ENCODING); if(data == null) data = ""; writer.write(data); writer.flush(); writer.close();

java中微信支付其一

5、public class MD5Util { private static String byteArrayToHexString(byte b[]) { StringBuffer resultSb = new StringBuffer(); for (int i = 0; i < b.length; i++) resultSb.append(byteToHexString(b[i])); return resultSb.toString(); } private static String byteToHexString(byte b) { int n = b; if (n < 0) n += 256; int d1 = n / 16; int d2 = n % 16; return hexDigits[d1] + hexDigits[d2]; }

java中微信支付其一

7、 private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; }已上的方法都是和网上一样的

java中微信支付其一
猜你喜欢