我需要读取hdfs中可用的.properties文件。我使用下面的代码,但它会引发运行时错误。使用java代码读取存储在hdfs中的.properties文件
FileSystem fs = FileSystem.get(config);
Properties conf = wc.createConfiguration();
Properties prop = new Properties();
String appPath = "hdfs://clusterdb05.com:8020/user/cmahajan/" + version + "/apps/apps/";
conf.setProperty(OozieClient.APP_PATH,appPath);
FileInputStream f = new FileInputStream("hdfs://clusterdb05.com:8020/user/cmahajan/app.properties");
ObjectInputStream f = new ObjectInputStream(fs.open(new Path("/user/cmahajan/app.properties")));
运行时间错误是:
LaunchJob.java:28: cannot find symbol
symbol : class ObjectInputStream
location: class LaunchJob
ObjectInputStream f = new ObjectInputStream(fs.open(new Path("/user/cmahajan/app.properties")));
^
LaunchJob.java:28: cannot find symbol
symbol : class ObjectInputStream
location: class LaunchJob
ObjectInputStream f = new ObjectInputStream(fs.open(new Path("/user/cmahajan/app.properties")));
什么是完整的代码,包括进口?这似乎是你缺少一个'import java.io.ObjectInputStream' – Alex
是的,这就是 – Chirag