首页 > 编程语言 > 详细

byte数组转16进制 输出到文件

时间:2016-07-21 17:59:48      阅读:230      评论:0      收藏:0      [点我收藏+]

 

try {
					
	File file = new File(Environment.getExternalStorageDirectory(),"shuju2"); 
	if(!file.exists()){
		file.createNewFile();
	}
	FileWriter fw = new FileWriter(file);
	BufferedWriter out = new BufferedWriter(fw);
	out.write(toHexString1(bytes));
	out.close();
	} catch (IOException e) {
	e.printStackTrace();
}
		


		
public static String toHexString1(byte[] b){
	StringBuffer buffer = new StringBuffer();
	for (int i = 0; i < b.length; ++i){
	buffer.append(toHexString1(b[i]));
	}
	return buffer.toString();
}
	

public static String toHexString1(byte b){
		String s = Integer.toHexString(b & 0xFF);
		if (s.length() == 1){
			return "0" + s;
		}else{
			return s;
		}
	}

  

 

byte数组转16进制 输出到文件

原文:http://www.cnblogs.com/wikiki/p/5692497.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!