apache-commons-io

FileUtils.copyFile() not creating file when destination is a network path (on windows)

∥☆過路亽.° 提交于 2020-08-25 04:24:28
问题 I'm using apache common's FileUtils.copyFile() to copy a file on a local disk to a network share location. The shared folder already exists, and the user running the app has permission to it. FileUtils.copyFile() executes with no exceptions. However, the file doesn't actually get created. File sourceFile = new File ("C:\\sourcefile.txt"); File destinationFile = new File("\\data-server\\my_share\\dest.txt"); // false System.out.println("Before copy, file exists? " + destinationFile.exists());

Java File commands over SSH

我们两清 提交于 2020-01-07 06:17:10
问题 I'm creating a java program which does a lot over ssh. In my program, I need to be able to run methods such as "listFiles()" on a remote host. I also need to be able to run a couple commands from Apache Commons io (I'm using the "FileUtils" class). I've seen programs such as JSch, but none of them have enough flexibility when it comes to file manipulation and transfer. Could anyone suggest an alternate program or approach to my problem? 回答1: On the contrary, JSch does support file transfer:

Java File commands over SSH

a 夏天 提交于 2020-01-07 06:15:12
问题 I'm creating a java program which does a lot over ssh. In my program, I need to be able to run methods such as "listFiles()" on a remote host. I also need to be able to run a couple commands from Apache Commons io (I'm using the "FileUtils" class). I've seen programs such as JSch, but none of them have enough flexibility when it comes to file manipulation and transfer. Could anyone suggest an alternate program or approach to my problem? 回答1: On the contrary, JSch does support file transfer:

Java process hanging on IOUtils. Suspected deadlock

流过昼夜 提交于 2019-12-23 12:55:43
问题 I have a java process that is hanging in a call to IOUtils.toString with the following code: String html = ""; try { html = IOUtils.toString(someUrl.openStream(), "utf-8"); // process hangs on this line } catch (Exception e) { return null; } It can't reproduce this reliably. It's part of a web crawler and so executes this line thousands of times successfully but ultimately causes the process to hang here after a few days. Output from jstack: 2013-09-25 09:09:36 Full thread dump OpenJDK 64-Bit

Android Studio3.2 APK Build Error -> reserved file or directory name 'lib'

笑着哭i 提交于 2019-12-23 12:15:36
问题 Android Studio Version 3.2 (AI-181.5540.7.32.5014246). In Android Studio 3.1, I was able to build SignedAPK successfully. But as soon as I made Android Studio 3.2, I could not build a SignedAPK at all. What is the cause of this problem? I have not written a path that puts commons-io under lib. The errors are as follows: File 'root/lib/commons-io-2.4.jar' uses reserved file or directory name 'lib'. org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app

Images are not appearing good when converted from .docx to pdf

柔情痞子 提交于 2019-12-22 10:23:02
问题 I converted .docx file to .pdf file, the text is converting fine, but the images in the .docx file is not appearing, instead it is represented as some special characters, below is my code: import com.lowagie.text.Document; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.PdfWriter; import java.io.File; import java.io.FileOutputStream; public class PDFConversion { /** * 14. This method is used to convert the given file to a PDF format 15. * * @param inputFile * - Name and the

commons io 403 for URL but httpclient is ok

被刻印的时光 ゝ 提交于 2019-12-12 12:11:53
问题 commons io code : String resultURL = String.format(GOOGLE_RECOGNIZER_URL, URLEncoder.encode("hello", "UTF-8"), "en-US"); URI uri = new URI(resultURL); byte[] resultIO = IOUtils.toByteArray(uri); I got this exception: Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://translate.google.cn/translate_tts?ie=UTF-8&q=hello&tl=en-US&total=1&idx=0&textlen=3 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)

Efficiently read file from URL into byte[] in Java

烈酒焚心 提交于 2019-12-12 11:27:38
问题 I'm trying to find a more efficient method of reading a file from a remote URL and saving it into a byte array. Here is what I currently have: private byte[] fetchRemoteFile(String location) throws Exception { URL url = new URL(location); InputStream is = null; byte[] bytes = null; try { is = url.openStream (); bytes = IOUtils.toByteArray(is); } catch (IOException e) { //handle errors } finally { if (is != null) is.close(); } return bytes; } As you can see, I currently pass the URL into the