java mas,java 移动MAS的DB接口实现彩信发送

/**

* 以字节为单位读取文件,常用于读二进制文件,如图片、声音、影像等文件。

* @param filePath彩信文件(.smil)的路径

*/

public  String readFileByBytes(String filePath){

String content="";

File file = new File(filePath);

ByteArrayOutputStream out = new ByteArrayOutputStream(1024);

InputStream in = null;

byte[] tempbytes = new byte[100];

try {

in = new FileInputStream(file);

int tempbyte=0;

while ((tempbyte = in.read(tempbytes)) != -1) {

out.write(tempbytes, 0, tempbyte);

}

in.close();

content= out.toString();

} catch (IOException e) {

e.printStackTrace();

}

finally {

if (in != null){

try {

in.close();

} catch (IOException e1) {

e1.printStackTrace();

}

}

}

return content;

}

/** * BASE64Encoder 加密,如果要实现彩信发送要把从文件读出的内容加密码再发到网关 * @param str * @return * @throws Exception */private String encrypt(String seacret) throws Exception {   if (seacret == null || seacret.equals("")) {    return "";   }   BASE64Encoder encoder = new BASE64Encoder();   return encoder.encode(seacret.getBytes());  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值