String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
"Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
"Linux", "OS/2" };
Log.d("list",TextUtils.join(",", values));
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
String a="hi is";
File myFile = new File("/sdcard/mysdcardfile.txt");
try {
myFile.createNewFile();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
//byte[] anotherArray = new byte[values.length];
byte data[] = new byte[1024];
int count;
long total = 0;
FileOutputStream output = new FileOutputStream(myFile);
while ((count = values.length) != -1) {
total += count;
// FileWriter fos = new FileWriter(myFile);
// BufferedWriter bis = new BufferedWriter(fos);
output.write(data, 0, count);
//bis.close();
//fos.close();
output.close();
}
ここで、値はテキスト形式でSDカードに保存されますが、テキストファイルを開くと、バイトが含まれています。ここでは、値はバイトに保存されます。ファイル出力ストリームを書き込むときに、バイトを文字列に変更する方法.テキストファイルの値。