导航:首页 > 操作系统 > android文件转byte

android文件转byte

发布时间:2023-06-15 06:28:42

1. android中怎么将音频文件转成Byte

为何要转呢?这个哥们也是不懂,你可以去看一下教程。http://www.eoeandroid.com/thread-565331-1-1.html

2. android如何把byte数据存到内存中并转为bitmap,求高手~~~~~~~~~~~~~~~~~~~~~~~~~~~

import java.io.File;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class MainAct extends Activity {
private ImageView img;
//图片路径
private String filepath = "/sdcard/sample.jpg";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
img = (ImageView) findViewById(R.id.img);
File file = new File(filepath);
if (file.exists()) {
Bitmap bm = BitmapFactory.decodeFile(filepath);
//将图片显示到ImageView中
img.setImageBitmap(bm);
}
}
}

请参考

3. android 字符串转byte数组

Android 字符串、byte数组与16进制数组间的转换

<spanstyle="font-family:SimSun;font-size:14px;">//字符串转换成16进制文字列的方法
publicStringtoHex(Stringstr){
StringhexString="0123456789ABCDEF";
byte[]bytes=str.getBytes();
StringBuilderhex=newStringBuilder(bytes.length*2);
for(inti=0;i<bytes.length;i++){
hex.append(hexString.charAt((bytes[i]&0xf0)>>4));//作用同n/16
hex.append(hexString.charAt((bytes[i]&0x0f)>>0));//作用同n
hex.append('');//中间用空格隔开
}
returnhex.toString();
}

//将16进制数组转换为字符串
publicstaticStringdecode(Stringbytes){
StringhexString="0123456789ABCDEF";
ByteArrayOutputStreambaos=newByteArrayOutputStream(bytes.length()/2);
//将每2位16进制整数组装成一个字节
//for(inti=0;i<bytes.length();i+=2)
//baos.write((hexString.indexOf(bytes.charAt(i))<<4|hexString.indexOf(bytes.charAt(i+1))));
//将每3位(第3位为空格)中的前2位16进制整数组装成一个字节
for(inti=0;i<bytes.length();i+=3){
baos.write((hexString.indexOf(bytes.charAt(i))<<4|hexString.indexOf(bytes.charAt(i+1))));
}
returnnewString(baos.toByteArray());
}</span>

详细

4. WebService返回byte[],在Android怎么才能接收byte[]啊,跪求大神

1、使用ISO 8859-1编码将字节数组转为字符串;

android接收到之后使用byte[] receive = String.getBytes("ISO 8859-1");


2、还可以将字节数组拼成字符串,用,符号隔开每个值。

Arrays.toString(byte[] b);可以将字节数组转成这种格式。

?

其实字节也是数值型。


importjava.io.UnsupportedEncodingException;
importjava.util.Arrays;
importjava.util.Random;
publicclassMainClass{
/**
*@paramargs
*/
publicstaticvoidmain(String[]args){
//TODO自动生成的方法存根
byte[]rand=newbyte[256];
newRandom().nextBytes(rand);
Stringtranslation=null;
try{
translation=newString(rand,"ISO-8859-1");
}catch(UnsupportedEncodingExceptione){
//TODO自动生成的catch块
e.printStackTrace();
}
System.out.println("要传输的内容:"+translation);
System.out.println("模拟传输过去...");
byte[]receive=null;
try{
receive=translation.getBytes("ISO-8859-1");
}catch(UnsupportedEncodingExceptione){
//TODO自动生成的catch块
e.printStackTrace();
}
System.out.println("传输前后的内容是否相同:"+Arrays.equals(rand,receive));
}
}

5. android上传图片到php android用bitmap.compress压缩为byte流 php怎么解压转为图片啊

android 文件上传,自己封装了个方法,
<?php
var_mp($_POST);
var_mp($_FILES);
foreach($_FILES as $key => $value){
move_uploaded_file($_FILES[$key]['tmp_name'],
$_SERVER['DOCUMENT_ROOT'].'/FileUpload/files/'.$_FILES[$key]['name']);
}
?>
PHP就这样接受了

阅读全文

与android文件转byte相关的资料

热点内容
在线充值平台源码 浏览:527
数字图像处理冈pdf 浏览:380
荣耀v6怎么隐藏桌面文件夹 浏览:798
程序员有女的吗 浏览:504
通讯服务器中断是为什么 浏览:644
itextpdf乱码 浏览:641
哪个app制作书法壁纸 浏览:196
暗梁支坐是否加密 浏览:341
51单片pdf 浏览:688
matlab编程习题 浏览:64
腾达wifi加密方式 浏览:121
ug平移命令 浏览:768
钉钉语音通话安全加密有什么特征 浏览:609
网购领券app哪个好靠谱 浏览:618
人民币数字加密币转账支付货币 浏览:634
怎么用cat命令创建mm 浏览:689
当今社会程序员好做吗 浏览:222
程序员那么可爱梓童第几集求婚 浏览:708
程序员大厂指南 浏览:777
ubuntupdf阅读器 浏览:4