i have the following code which runs without error and writes the output file successfully. However, i am not able to open the output file. it always prompts me an error saying "word found unreadable content"
anyone can advise if there is anything wrong with my code?
`File inputf = new File("C:\\Appl\\CM table deployment.docx");
File outputf = new File("C:\\Appl\\CM table deployment1.docx");
RandomAccessFile infile = new RandomAccessFile(inputf, "r");
RandomAccessFile outfile = new RandomAccessFile(outputf, "rw");
FileChannel inChannel = infile.getChannel();
FileChannel outChannel = outfile.getChannel();
ByteBuffer inbuffer = ByteBuffer.allocate(1024*64);
long position = 0;
System.out.println("inChannel.size(): " + inChannel.size());
while(inChannel.read(inbuffer) > 0)
{
inbuffer.flip();
ByteBuffer outbuffer;
if(position+inbuffer.capacity()<inChannel.size())
outbuffer = ByteBuffer.allocate(1024*64);
else
outbuffer = ByteBuffer.allocate((int)(inChannel.size()-position+1));
outbuffer.put(inbuffer.get());
while (outbuffer.hasRemaining()){
outChannel.write(outbuffer, position);
if(position+inbuffer.capacity()<inChannel.size()){
position = position + inbuffer.capacity();
System.out.println("next position : "+ position);
}
else{
position = position+1;
System.out.println("next position : "+ position);
}
}
outbuffer.clear();
inbuffer.clear(); // do something with the data and clear/compact it.
}
inChannel.close();
outChannel.close();
infile.close();
outfile.close();
`