FileGather.java


Dosyayı İndir
package com.godoro.nio.buffer;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.GatheringByteChannel;

public class FileGather {

  public static void main(String[] args) throws Exception {
    String path = "gatherscatter.txt";
    int number=1234;
    String text = "Godoro Java Database";
    
    ByteBuffer buffer1 = ByteBuffer.allocate(1024);
    buffer1.asIntBuffer().put(number);
    
    ByteBuffer buffer2 = ByteBuffer.allocate(1024);
    buffer2.asCharBuffer().put(text);
    
    FileOutputStream out = new FileOutputStream(path);
    GatheringByteChannel gathering = out.getChannel();
    gathering.write(new ByteBuffer[]{buffer1, buffer2});
    out.close();
    gathering.close();

  }
}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir