【发布时间】:2011-10-19 12:55:50
【问题描述】:
我正在使用 Eclipse。有谁知道这段代码试图从哪里获取文件? 我已将文件复制到项目文件夹以及 srr/package_path 文件夹。
public String getFromFile(ASerializer aserializer) {
String data = new String();
try {
FileInputStream stream = new FileInputStream(new File(aserializer.toLocalResource()));
FileChannel fc = stream.getChannel();
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
/* Instead of using default, pass in a decoder. */
data = Charset.defaultCharset().decode(bb).toString();
stream.close();
}
catch (Exception e){
data = "File not found";
}
return data;
}
【问题讨论】:
-
请提供更多关于
ASerializer类的信息 -
序列化器只返回文件名。我只是不知道 getFromFile 在哪里看。什么是默认文件夹?
标签: android eclipse file local