码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2016-07-21 18:00:08      阅读:190      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!