NIO: no data written

T

Timo Nentwig

Hi!

final File fin = new File( args[ 0 ] );
final File fout = new File( args[ 1 ] );

final FileChannel in = new FileInputStream( fin ).getChannel();
final FileChannel out = new
FileOutputStream( fout ).getChannel();

final ByteBuffer buf = ByteBuffer.allocate( 2048 );

int j;
j = in.read( buf, seek_header );
System.out.println("read: " + j);
j = out.write( buf );
System.out.println("written: " + j);

This outputs:

read: 2048
written: 0

Why doesn't it write the data? The new file is created but nothing is
written in to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top