集册 Java实例教程 对无缓冲写入使用newOutputStream()方法

对无缓冲写入使用newOutputStream()方法

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

750
使用newOutputStream()方法进行无缓冲写入

import java.io.IOException;

import java.io.OutputStream;

import java.nio.file.Files;

import java.nio.file.Path;//N o w  J a v a  . c o m 提供

import java.nio.file.Paths;


public class Main {

  public static void main(String[] args) {


    Path path = Paths.get("C:/folder1/equipment", "test.txt");

    String str = "test";


    byte data[] = str.getBytes();

    try (OutputStream outputStream = Files.newOutputStream(path)) {

      outputStream.write(da
展开阅读全文