If you don't know why something didn't work out, it's a bad idea to ignore exceptions in an empty try-catch block.
The odds are excellent that you run the program in an environment where the file cannot be created; however, the instructions you gave to deal with such an exceptional situation do nothing. So, the likelihood that you have a program that tried to run, but for some reason failed, and this was due to the fact that you did not even indicate the reason.
try it
public static void copy(String fileOutName, boolean append){ File fileOut = new File (fileOutName); try { FileChannel wChannel = new FileOutputStream(fileOut, append).getChannel(); int i = 5; ByteBuffer bb = ByteBuffer.allocate(4); bb.order(ByteOrder.LITTLE_ENDIAN); bb.putInt(i); bb.flip(); int written = wChannel.write(bb); System.out.println(written); wChannel.close(); } catch (IOException e) {
And I bet you will find out why this doesn't work right away.
source share