读取流

@Test
    public void run2() throws IOException{//写入数据
        Configuration conf = new Configuration();
        FileSystem fs = null;
        BufferedWriter bufferedWriter =null;
        try {
            fs = FileSystem.newInstance(conf);//hadoop加载配置文件
            Path path = new Path("/workspace/hyt/day5/word.txt");
            FSDataOutputStream out = fs.append(path);//hadoop追加到文件的fs数据输出流
            OutputStreamWriter writer = new OutputStreamWriter(out);//调用java输出流
             bufferedWriter = new BufferedWriter(writer);//加载到java输入缓冲流
            for(int i=0;i<10;i++) {
                bufferedWriter.append("data"+i);
                bufferedWriter.newLine();
                System.out.println("data"+i);
            }
        } catch (IOException e) {

            e.printStackTrace();
        }finally {
            if(bufferedWriter!=null)
            bufferedWriter.close();
            if(fs!=null)
                fs.close();
        }


    }

删除

public void run3() throws IOException {
        Configuration conf = new Configuration();
        FileSystem fs = FileSystem.newInstance(conf);
        Path path= new Path("/workspace/hyt/day5/word.txt");
        if(fs.exists(path)) {
            System.out.println("---exits---");
            fs.delete(path);
        }
        System.out.println("---over--");
        fs.close();
    }