0

FileUtils.copyDirectory fails with a remote file larger than 7 megas

Imports:

import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;

Code:

String source = fm_dirIn;
File srcDir = new File(source);

// The destination directory to copy to. This directory
// doesn't exists and will be created during the copy
// directory process.
String destination = fm_dirOut;
File destDir = new File(destination);

try {
    // Copy source directory into destination directory
    // including its child directories and files. When
    // the destination directory is not exists it will
    // be created. This copy process also preserve the
    // date information of the file.
    FileUtils.copyDirectory(srcDir, destDir);
    return true
} catch (IOException e) {
    'Erreur : ' + e.printStackTrace();
}

Result

Erreur : null and the copied list files stops on this file at 7040kb (it's 31944 KB)

the printStackTrace :

Current stack trace is:java.io.IOException: Erreur réseau inattendue at sun.nio.ch.FileDispatcherImpl.pwrite0(Native Method) at sun.nio.ch.FileDispatcherImpl.pwrite(Unknown Source) at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source) at sun.nio.ch.IOUtil.write(Unknown Source) at sun.nio.ch.FileChannelImpl.writeInternal(Unknown Source) at sun.nio.ch.FileChannelImpl.write(Unknown Source) at sun.nio.ch.FileChannelImpl.transferFromFileChannel(Unknown Source) at sun.nio.ch.FileChannelImpl.transferFrom(Unknown Source) at org.apache.commons.io.FileUtils.doCopyFile(FileUtils.java:1131) at org.apache.commons.io.FileUtils.doCopyDirectory(FileUtils.java:1424) at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1366) at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1246) at org.apache.commons.io.FileUtils.copyDirectory(FileUtils.java:1215) at org.apache.commons.io.FileUtils$copyDirectory.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at Script1.run(Script1.groovy:27) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:518) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:556) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:527) at com.prosc.beanshell.BeanShellModel.evaluateGroovy(BeanShellModel.java:163) at com.prosc.beanshell.BeanShellPlugin.EvaluateGroovy(BeanShellPlugin.java:603) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.prosc.fmkit.StaticFunction.invoke(StaticFunction.java:231) at com.prosc.fmkit.Plugin.invokeFunction(Plugin.java:339) at com.prosc.fmkit.RegisterablePlugin.invokeFunction(RegisterablePlugin.java:146) at com.prosc.fmkit.Plugin.invokeFunctionNoErrors(Plugin.java:320) at com.prosc.fmkit.PluginBridge$3.run(PluginBridge.java:1132) at com.prosc.fmkit.PluginBridge$5.run(PluginBridge.java:1234) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)

ericire
  • 409
  • 6
  • 22
  • 2
    This doesn't compile. Please add the actual code and full stack trace. – Piotr Praszmo Jul 05 '19 at 19:04
  • For your information, since Java 1.7 you can copy a directory using the JDK. See [Copying a File or Directory](https://docs.oracle.com/javase/tutorial/essential/io/copy.html) – Abra Jul 05 '19 at 19:10
  • HI. this is the actual code and full stack trace. I use it in a filemaker plugin that runs java or groovy – ericire Jul 05 '19 at 19:44
  • If this is Groovy please tag as groovy. You have to improve your catch block. `printStackTrace()` prints the stack trace to stderr and doesn't return anything. Try removing catch block completely. – Piotr Praszmo Jul 05 '19 at 20:08
  • without catch > message box : java.io.IOException: Erreur réseau inattendue and in english : java.io.IOException: Unexpected network error – ericire Jul 05 '19 at 20:48
  • 1
    it is possible that the parameters of the vpn disrupt the script ? – ericire Jul 05 '19 at 21:13
  • Fix a way how you get an error. printStackTrace returns no value (check the doc) that's why you have `erreur null` message. If your program has console or maybe log, the printStackTrace should print full error to it. Or you could use the following technique to get full error in string and return it : https://stackoverflow.com/questions/1149703/how-can-i-convert-a-stack-trace-to-a-string – daggett Jul 06 '19 at 08:37
  • the printStackTrace is too long I put it as answer – ericire Jul 06 '19 at 10:07
  • yes I add the all printStackTrace in the question – ericire Jul 06 '19 at 14:12
  • 1
    `Unexpected network error` issue not about the code, but about network restrictions. And you have to look for resolution on network/system administration forums. – daggett Jul 06 '19 at 14:26
  • ok Thank you ;) – ericire Jul 06 '19 at 17:22

0 Answers0