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


 

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;
		}
	}

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM