zoukankan      html  css  js  c++  java
  • 大型数据库技术(一)

    package hjy.hadoop;

    import java.io.FileOutputStream;

    import java.io.IOException;

    import java.net.URI;

    import java.net.URISyntaxException;

    import org.apache.hadoop.conf.Configuration;

    import org.apache.hadoop.fs.FSDataInputStream;

    import org.apache.hadoop.fs.FileSystem;

    import org.apache.hadoop.fs.Path;

    public class MyFSDataInputStream {

    public static void main(String[] args) throws IOException, InterruptedException, URISyntaxException {

    FileSystem fs = null;

    FSDataInputStream fsdInputStream = null;

    FileOutputStream fos = null;

    fos = new FileOutputStream("d:/hhd.txt");

    Configuration conf = new Configuration();

    conf.set("fs.defaultFS", "hdfs://hjy:9000");

    fs = FileSystem.get(new URI("hdfs://hjy:9000"),conf,"hadoop");

     Path srcPath = new Path("hdfs://hjy:9000/aa/qingshu.txt");

     fsdInputStream = fs.open(srcPath);

     byte[] buff = new byte[1024];

             int readCount = 0;

             readCount = fsdInputStream.read(buff);

             if(readCount==-1) {

              System.out.println("文本为空!");

              System.exit(0);

             }

             while (readCount != -1) {

              fos.write(buff, 0, readCount);

                 System.out.println(new String(buff, 0, readCount));   //阅读文本内容

                 readCount = fsdInputStream.read(buff); //下载文本内容

             }

             fos.close();

    }

    }

    截图:

     

  • 相关阅读:
    HDU 3709 数位dp
    Educational Codeforces Round 64 (Rated for Div. 2)-C. Match Points
    POJ 1845乘法逆元+约数和
    POJ3696 欧拉定理
    NC24953 树形dp(最小支配集)
    Codeforces 1173 C 思维+模拟
    Codeforces 1324F 树形dp+换根
    codeforces-1285D(字典树)
    面向纯小白的CLion(C++)基于Windows的安装配置教程
    HDU-2825Wireless Password(AC自动机+状压DP)
  • 原文地址:https://www.cnblogs.com/goubb/p/11524892.html
Copyright © 2011-2022 走看看