導航:首頁 > 操作系統 > 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相關的資料

熱點內容
類似7z002的壓縮文件如何解壓 瀏覽:559
移動dsn伺服器地址 瀏覽:689
90後女性嫁給程序員 瀏覽:302
fcm演算法原理 瀏覽:803
上海興力壓縮機 瀏覽:699
什麼app可以推送小區 瀏覽:592
韓國解壓視頻網站 瀏覽:619
做庫管用什麼app 瀏覽:35
pdf轉dwg怎麼轉 瀏覽:55
單片機微小電阻測量 瀏覽:138
表格25兆怎麼壓縮 瀏覽:69
java開發公司的 瀏覽:131
東風天錦壓縮車工作指示燈不亮 瀏覽:985
劍俠情緣1源碼 瀏覽:532
cad2011怎麼轉換成pdf格式 瀏覽:966
傳祺gs5安卓車機如何還原車機 瀏覽:900
單片機和編程器互相傳輸數據 瀏覽:92
app訂單怎麼取消 瀏覽:469
程序員用雙顯示器有什麼作用 瀏覽:613
網約車演算法殺熟 瀏覽:8