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

熱點內容
資料庫查詢系統源碼 瀏覽:617
php5314 瀏覽:358
完美國際安裝到哪個文件夾 瀏覽:669
什麼app可以掃一掃做題 瀏覽:540
程序員編碼論壇 瀏覽:924
淘點是什麼app 瀏覽:660
中國高等植物pdf 瀏覽:454
51單片機時間 瀏覽:182
後台如何獲取伺服器ip 瀏覽:267
單片機流水燈程序c語言 瀏覽:236
程序員第二職業掙錢 瀏覽:240
運行里怎麼輸入伺服器路徑 瀏覽:843
pythonstepwise 瀏覽:512
劉一男詞彙速記指南pdf 瀏覽:66
php認證級別 瀏覽:371
方舟編譯啥時候推送 瀏覽:1012
php手機驗證碼生成 瀏覽:677
哲學思維pdf 瀏覽:17
凌達壓縮機有限公司招聘 瀏覽:535
weblogic命令部署 瀏覽:39