2
創建文件,我想創建在Android JUNIT測試用例上建立一個文件:Android中的JUnit
protected void setUp() throws Exception {
super.setUp();
File storageDirectory = new File("testDir");
storageDirectory.mkdir();
File storageFile = new File(storageDirectory.getAbsolutePath()
+ "/test.log");
if (!storageFile.exists()) {
storageFile.createNewFile();
}
mContext = new InternalStorageMockContext(storageFile);
mContextWrapper = new ContextWrapper(mContext);
}
我得到一個異常沒有這樣的文件或目錄當我打電話createNewFile。有沒有從Android JUNIT創建文件的標準方法?