我通过flutter中的一个通道调用java代码。它工作,但当我试图读取我的文件,它没有找到该文件,并抛出我一个例外。我尝试了所有类型的路由,但它根本找不到文件,以下是我的文件结构:
我用来获取文件的代码是:
public class MainActivity extends FlutterActivity {
private static final String CHANNEL = "prueba/cien";
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine);
new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL)
.setMethodCallHandler(
(call, result) -> {
if(call.method.equals("main")){
try {
ArrayList<String> sintomas = call.argument("sintomas");
ArrayList<String> signos = call.argument("signos");
ArrayList<ArrayList<String>>[] resultado = main(sintomas,signos);
result.success(resultado);
} catch (IOException e) {
e.printStackTrace();
}
}
}
);
}
private ArrayList<ArrayList<String>>[] main(ArrayList<String> sintomas,ArrayList<String> signos) throws IOException {
dataReader dr = new dataReader("texts/enfermedadPaciente.txt");
dataReader dr2 = new dataReader("texts/enfermedadPaciente.txt");
}
}
读取器类构造函数是:
public class dataReader{
public dataReader(String path){
this.file = new File(path);
try{
this.br = new BufferedReader(new FileReader(file));
}
catch (FileNotFoundException ex){
System.out.println("File not found in "+path);
}
}
}
暂无答案!
目前还没有任何答案,快来回答吧!