Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 3rd, 2013  |  syntax: None  |  size: 1.43 KB  |  hits: 76  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package mypack;
  2.  
  3. import org.apache.hadoop.conf.Configuration;
  4. import org.apache.hadoop.fs.FSDataInputStream;
  5. import org.apache.hadoop.fs.FileSystem;
  6. import org.apache.hadoop.fs.Path;
  7. import org.apache.hadoop.io.BytesWritable;
  8. import org.apache.hadoop.io.IOUtils;
  9. import org.apache.hadoop.io.SequenceFile;
  10. import org.apache.hadoop.io.Text;
  11.  
  12. public class ImageToSeq {
  13.         public static void main(String args[]) throws Exception {
  14.                
  15.                 Configuration confHadoop = new Configuration();        
  16.                 confHadoop.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/core-site.xml"));
  17.                 confHadoop.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/hdfs-site.xml"));  
  18.                 FileSystem fs = FileSystem.get(confHadoop);
  19.                 Path inPath = new Path("/mapin/1.png");
  20.                 Path outPath = new Path("/mapin/11.png");
  21.                 FSDataInputStream in = null;
  22.                 Text key = new Text();
  23.                 BytesWritable value = new BytesWritable();
  24.                 SequenceFile.Writer writer = null;
  25.                 try{
  26.                         in = fs.open(inPath);
  27.             byte buffer[] = new byte[in.available()];
  28.             in.read(buffer);
  29.             writer = SequenceFile.createWriter(fs, confHadoop, outPath, key.getClass(),value.getClass());
  30.                         writer.append(new Text(inPath.getName()), new BytesWritable(buffer));
  31.                 }catch (Exception e) {
  32.                         System.out.println("Exception MESSAGES = "+e.getMessage());
  33.                 }
  34.                 finally {
  35.                         IOUtils.closeStream(writer);
  36.                         System.out.println("last line of the code....!!!!!!!!!!");
  37.                 }
  38.         }
  39. }