在下面的代码中,我想创建一个SD卡中的文件。但它没有给出任何有效的输出。仅显示hello world ...在哪里显示“文件创建”消息以及文件的存储位置?android未能显示结果
package com.read;
import java.io.FileOutputStream;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
public class read extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String FILENAME = "hello_file";
String string = "hello world!";
try{
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
}catch(Exception e){}
System.out.println("File created");
}
}
它的工作原理..谢谢 – vnshetty 2011-02-24 07:19:53