package com.godoro.nio.channel;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class FileWrite {
public static void main(String[] args) throws Exception{
String path = "output.txt";
String text="Godoro\r\nJava\r\nDatabase\r\nNIO";
ByteBuffer buffer=ByteBuffer.wrap(text.getBytes());
RandomAccessFile file = new RandomAccessFile(path, "rw");
FileChannel channel = file.getChannel();
channel.write(buffer);
channel.close();
System.out.println("Dosya içeriği yazıldı.");
}
}
Dosyayı İndir