联合国

欢马劈雪     最近更新时间:2020-01-02 10:19:05

509
Files类中的无缓冲IO支持

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;/* 来 自 时 代 J a v a*/

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;

import java.nio.file.StandardOpenOption;


public class Main {

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

    try {

      Path file = Paths.get("/home/docs/users.txt");

      Path newFile = Paths.get("/home/docs/newUsers.txt");

      try (InputStream in = Files.newInputStream(file);

          OutputStream out = Files.newOutputStream(newFile, StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {
          /* from 
          n o w  j a v a  . c o m*/

        int data = in.read();

     
展开阅读全文