String url="/data/data/com.dragon/adv/advert.dat";
File file =new File(url);
try{
if(!file.exists())
file.mkdirs();
file.delete();
file.createNewFile();
FileOutputStream dos=openFileOutput("advert.dat", MODE_PRIVATE);
String str="************* info===>>>>>>>>";
byte []content=str.getBytes();
dos.write(content);
dos.close();
dos.close();
FileInputStream fis=openFileInput("advert.dat");
int len=fis.available();
byte rad[]=new byte [len];
fis.read(rad);
fis.close();
String pr=new String(rad,"UTF-8");
System.out.println(""+pr);
}catch(Exception ex){
ex.printStackTrace();
}就这么个文件读写操作的问题 新建的android 工程里就可以正常的 写入,读取放到android项目里就报空指针。。ddms查看手机内存里也确实存在这个文件路径和文件...。 谁知道怎么回事啊
File file =new File(url);
try{
if(!file.exists())
file.mkdirs();
file.delete();
file.createNewFile();
FileOutputStream dos=openFileOutput("advert.dat", MODE_PRIVATE);
String str="************* info===>>>>>>>>";
byte []content=str.getBytes();
dos.write(content);
dos.close();
dos.close();
FileInputStream fis=openFileInput("advert.dat");
int len=fis.available();
byte rad[]=new byte [len];
fis.read(rad);
fis.close();
String pr=new String(rad,"UTF-8");
System.out.println(""+pr);
}catch(Exception ex){
ex.printStackTrace();
}就这么个文件读写操作的问题 新建的android 工程里就可以正常的 写入,读取放到android项目里就报空指针。。ddms查看手机内存里也确实存在这个文件路径和文件...。 谁知道怎么回事啊
<uses-permission android:name="android.permission.RIDE_EXTERNAL_STORAGE" />是这两 个 没错把