Problème pagination lors d'une copie
Bonjour,
J'ai besoin de copier une grosse quantité de jar et j'ai créé un petit programme.
Je rencontre le poblème suivant lorsqu'il essaye de copier certains jar par moment:
Code:
1 2 3 4 5 6 7 8 9 10
|
java.io.IOException: Erreur lors dune opération de pagination
at sun.nio.ch.FileDispatcher.write0(Native Method)
at sun.nio.ch.FileDispatcher.write(FileDispatcher.java:44)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:104)
at sun.nio.ch.IOUtil.write(IOUtil.java:60)
at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:203)
at sun.nio.ch.FileChannelImpl.transferToTrustedChannel(FileChannelImpl.java:449)
at sun.nio.ch.FileChannelImpl.transferTo(FileChannelImpl.java:520)
at RetrieveAllJars.copyFile(RetrieveAllJars.java:31) |
Voici le code de copie trouvé dans la FAQ de ce forum:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
private static void copyFile(final File source, final File dest) {
FileChannel in = null;
FileChannel out = null;
try {
// Init
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
// Copie depuis le in vers le out
in.transferTo(0, in.size(), out);
} catch (final Exception e) {
e.printStackTrace(); // n'importe quelle exception
} finally { // finalement on ferme
if (in != null) {
try {
in.close();
} catch (final IOException e) {
}
}
if (out != null) {
try {
out.close();
} catch (final IOException e) {
}
}
}
} |
Quelqu'un a t-il connaissance de ce problème? J'ai cherché sur internet pour ce type de problème avec transfertTo() mais n'ai pas trouvé de solution.
Merci d'avance.