【发布时间】:2014-12-15 21:22:53
【问题描述】:
下面是我在 MainActivity 类中的子类 crawlerSub 的 sn-p:
class crawlerSub 扩展 AsyncTask { 私有 int 计数 = 0;
@Override protected Void doInBackground(Void... params) { try { Crawler.crawler("http://www.ipmart.com.my", 10); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void aVoid) { File file = null; FileOutputStream fos = null; try { file = this.getFilesDir(); fos = this.openFileOutput("visitedLinks", Context.MODE_PRIVATE); for (String link : Crawler.visitedLinks) { fos.write(link.getBytes()); } } catch (FileNotFoundException e) { Log.d("Log", e.toString()); } catch (IOException e) { Log.d("Log", e.toString()); } finally { try { fos.close(); } catch (IOException e) { Log.d("Log", e.toString()); } } Toast.makeText(ctx, "File saved to " + file, Toast.LENGTH_SHORT).show() } }
我的问题在于这两行代码:
file = this.getFilesDir(); fos = this.openFileOutput("visitedLinks", Context.MODE_PRIVATE);
当我使用“this.getFilesDir()”时,它给了我“无法解决方法错误” 我该如何解决这个问题?谢谢。
【问题讨论】:
标签: java android android-asynctask