2012-02-29 7 views

答えて

2

をバイト配列に変換した後、この

AssetManager mngr = getAssets(); 
InputStream path = mngr.open("music/music1.mp3"); 

        BufferedInputStream bis = new BufferedInputStream(path,1024); 

        //get the bytes one by one 
        int current = 0; 

        while ((current = bis.read()) != -1) { 

         baf.append((byte) current); 
        } 
} 
byte[] bitmapdata = baf.toByteArray(); 

をしてみてください助けてください、私はファイル

String filename = "filename.txt"; 
File file = new File(Environment.getExternalStorageDirectory(), filename); 
FileOutputStream fos; 
byte[] data = new String("data to write to file").getBytes(); 
try { 
    fos = new FileOutputStream(file); 
    fos.write(data); 
    fos.flush(); 
    fos.close(); 
} catch (FileNotFoundException e) { 
    // handle exception 
} catch (IOException e) { 
    // handle exception 
} 

を保存するために使用していたコードである

を次のようにSDカードにこれをコピーします
File file = new File(Environment.getExternalStorageDirectory(), music1.mp3); 
FileOutputStream fos; 

try { 
    fos = new FileOutputStream(file); 
    fos.write(bitmapdata ); 
    fos.flush(); 
    fos.close(); 
} catch (FileNotFoundException e) { 
    // handle exception 
} catch (IOException e) { 
    // handle exception 
} 
+0

ありがとうあなたに戻ってみてください。 – Goofy

+0

ここには何のバフですか? – Goofy

+0

ByteArrayBuffer baf =新しいByteArrayBuffer(1024); – user1203673

関連する問題