hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank LIN" <woodsd...@gmail.com>
Subject How do I read a file to a buffer from HDFS?
Date Thu, 06 Sep 2007 04:29:40 GMT
Hi all,

For some reasons, I need to read a small fine into memory from HDFS. I tried:

    final Path file = new Path(...) // file name on HDFS
    byte[] buffer = new byte[100000];
    try {
        FileSystem fs = FileSystem.get(conf);
        FSDataInputStream fileIn = fs.open(file);
        fileIn.readFully(buffer);
    } catch (Exception e) {
        System.err.println(e.toString());
    }

but the "fileIn.readFully(buffer)" always throws a EOF exception.

Any suggestions on that? Thank you.


-- 
Frank Lin
Undergraduate Student
Dept. Computer Science and Technology,
Tsinghua University, Beijing, P.R.China

Mime
View raw message