System.getProperty("user.dir")
+ System.getProperty("file.separator")
public static String amtLee2Yuan(String amt_pay) { int scale = 2; BigDecimal b1 = new BigDecimal(amt_pay); BigDecimal b2 = new BigDecimal(1000); return b1.divide(b2, scale, BigDecimal.ROUND_FLOOR).toPlainString(); }
public enum TransCodeEnum { singlePay("022C"), singleQuery("0228"); String code; private TransCodeEnum(String code) { this.code = code; } public String getCode() { return this.code; } }
/** * 为指定文本内容在前面添加“0” * * @param content * 指定内容。 * @param digit * 文本预置长度。 * @return 补全空格后的文本。参数错误时返回<code>null</code>。 */ public static String lengthFilter(String content, int digit) { if (content == null) { content = ""; } int len = content.length() - digit; if (len > 0) { logger.error("文本内容[content:" + content + ",len:" + content.length() + "]超过指定长度[len:" + digit + "]"); return null; } StringBuffer res = new StringBuffer(digit); res.append(content); if (len < 0) { for (int i = 0; i < (-len); i++) { res.insert(0, "0"); } } return res.toString(); }
/** * 读文件 * * @param file * @return * @throws Exception */ public static byte[] readFile(File file) { BufferedInputStream in = null; ByteArrayOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(file)); out = new ByteArrayOutputStream(); byte[] temp = new byte[1024]; int size = 0; while ((size = in.read(temp)) != -1) { out.write(temp, 0, size); } return out.toByteArray(); } catch (Exception e) { } finally { try { if (null != out) out.close(); if (null != in) in.close(); } catch (Exception e2) { } } return null; } /** * 补位 * * @param byte_array * @return */ public static byte[] paddingByte(byte[] byte_array) { int length = byte_array.length; int mode = length % 8; int times = 0; if (mode != 0) times = 8 - mode; byte[] sendByte = new byte[length + times]; for (int i = 0; i < length; i++) { sendByte[i] = byte_array[i]; } for (int j = length; j < length + times; j++) { sendByte[j] = 0x00; } return sendByte; }