我有一个bin文件en-parser-chunking.bin,它在我的项目中做块部分,我正在使用它,如下所示
InputStream modelInParse = null;
try {
//load chunking model
Log.i(TAG,"1");
modelInParse = new FileInputStream("en-parser-chunking.bin");但这是在android中抛出一个IO异常。我也在我的项目文件中。
发布于 2015-04-13 10:13:21
可能是这样的
InputStream modelInParse = null;
try {
//load chunking model
Log.i(TAG,"1");
modelInParse = new FileInputStream("Relative/or/absolute/path/of/your/.bin/file");系统无法找到您的文件。所以这就是IO的例外。请正确地给出文件路径
发布于 2017-03-09 01:31:14
resources文件夹中(我在单元测试中使用.bin文件,因此我将其保存在app-name/app/src/test/resources中)ClassLoaderpublic InputStream openBin(String filename) throws IOException { lassLoader classLoader = this.getClass().getClassLoader(); File file = new File(classLoader.getResource(filename).getPath()); InputStream input = new FileInputStream(file); return input; }打开文件https://stackoverflow.com/questions/29602728
复制相似问题