public void configure(JobConf job) {
inputFile = job.get("map.input.file");
Path[] cacheFiles = new Path[2];
try {
Path file0 = DistributedCache.getLocalCacheFiles(job)[0];
Path file1 = DistributedCache.getLocalCacheFiles(job)[1];
} catch (IOException ioe) {
System.err.println("Caught exception while getting cached files: " + StringUtils.stringifyException(ioe));
}
}
我在configure函数中编写代码。
现在如何从路径file0和file1获取文件名?我需要文件名,因为我需要将两个文件中的数据存储到两个单独的Hashmap中。
请尝试以下操作:
Path file0 = DistributedCache.getLocalCacheFiles(job)[0];
Path file1 = DistributedCache.getLocalCacheFiles(job)[1];
String filename0 = file0.getName();
String filename1 = file1.getName();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句