Use the Seek () method to display a file on the Hadoop file system two times on standard output
Package com;
Import java.io.IOException;
Import Java.net.URI;
Import org.apache.hadoop.conf.Configuration;
Import Org.apache.hadoop.fs.FSDataInputStream;
Import Org.apache.hadoop.fs.FileSystem;
Import Org.apache.hadoop.fs.Path;
Import Org.apache.hadoop.io.IOUtils;
public class Filesystemdoublecat {
/**
* @param args
* @throws IOException
*/
public static void Main (string[] args) throws IOException {
TODO auto-generated Method Stub
String uri = args[0];
Configuration conf = new configuration ();
FileSystem fs = Filesystem.get (Uri.create (URI), conf);
Fsdatainputstream in = null;
try{
in = Fs.open (new Path (URI));
Ioutils.copybytes (in, System.out, 4096, false);
In.seek (0);
Ioutils.copybytes (in, System.out, 4096, false);
}finally{
Ioutils.closestream (in);
}
}
}
Use the Seek () method to display a file on the Hadoop file system two times on standard output