android.app.Application.openFileInput()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中android.app.Application.openFileInput()方法的一些代码示例,展示了Application.openFileInput()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.openFileInput()方法的具体详情如下:
包路径:android.app.Application
类名称:Application
方法名:openFileInput

Application.openFileInput介绍

暂无

代码示例

代码示例来源:origin: roomanl/AndroidDownload

@Override
public FileInputStream openFileInput(String name) throws FileNotFoundException {
  Log.d(TAG,"----getBaseContext");
  return app.openFileInput(name);
}

代码示例来源:origin: mapsforge/mapsforge

public FileInputStream openFileInput(String name) throws FileNotFoundException {
  if (this.svgCacheDir != null) {
    return new FileInputStream(new File(this.svgCacheDir, name));
  }
  return this.application.openFileInput(name);
}

代码示例来源:origin: gdpancheng/LoonAndroid3

public  <T> T getObject(String fileName) {
    long time = System.currentTimeMillis();
    FileInputStream fis = null;
    ObjectInputStream ois = null;
    try {
      if (!new File(fileName).exists()) {
        return null;
      }
      fis = application.openFileInput(fileName); // 获得输入流
      ois = new ObjectInputStream(fis);
      return (T) ois.readObject();
    } catch (Exception e) {
    } finally {
      try {
        if (fis != null) {
          fis.close();
        }
        if (ois != null) {
          ois.close();
        }
      } catch (IOException e) {
      }
    }
    return null;
  }
}

代码示例来源:origin: gdpancheng/LoonAndroid3

/**
 * 读取文件 文件在/data/data/package_name/files下 无法指定位置
 * 
 * @author 潘城 gdpancheng@gmail.com 2012-6-27 下午12:49:08
 * @param fileName
 * @return 设定文件
 */
public static Properties loadConfigNoDirs(String fileName) {
  Properties properties = new Properties();
  try {
    FileInputStream s = Ioc.getIoc().getApplication().openFileInput(fileName);
    properties.load(s);
  } catch (Exception e) {
    Ioc.getIoc().getLogger().e(e.toString());
  }
  return properties;
}

代码示例来源:origin: gdpancheng/LoonAndroid3

public static <T> T getObject(String fileName) {
  long time = System.currentTimeMillis();
  FileInputStream fis = null;
  ObjectInputStream ois = null;
  try {
    fis = Ioc.getIoc().getApplication().openFileInput(fileName); // 获得输入流
    ois = new ObjectInputStream(fis);
    return (T) ois.readObject();
  } catch (Exception e) {
    Ioc.getIoc().getLogger().d(fileName + " 序列化文件不存在");
  } finally {
    try {
      if (fis != null) {
        fis.close();
      }
      if (ois != null) {
        ois.close();
      }
    } catch (IOException e) {
    }
  }
  Ioc.getIoc().getLogger().d(fileName + " 序列化存储耗时为:" + (System.currentTimeMillis() - time));
  return null;
}

相关文章

微信公众号

最新文章

更多

Application类方法