我需要读取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")));
2条答案
按热度按时间ppcbkaq51#
使用类的完全限定名:
或
使用以下行导入类:
91zkwejq2#
对于从hdfs加载属性文件:
确保ur core site.xml、hdfs site xml文件路径
hdfs端口号(将在core site.xml中提供)
替换getproperty中的键。