Questions tagged [fileutils]

FileUtils is a File manipulation utility from Apache Commons

FileUtils or org.apache.commons.io.FileUtils is File manipulation utility from Apache Commons

234 questions
0
votes
3 answers

Exception java FileUtils.readFileToByteArray when trying to readFileToByteArray

My text file, mombirthday.txt, is in the same eclipse directory as my src file. But an exception is being thrown (file does not exist). I've tried using a qualified path to the file with another exception being thrown. I've found countless examples…
popster
  • 31
  • 1
  • 2
0
votes
1 answer

Files/Paths/FileUtils - Mock several static classes in one test

I have to mock the below method: public static void cleanAndCreateDirectories(@NonNull final Path path) throws IOException { // If download directory exists(should not be symlinks, clear the contents. System.out.println(path); …
bit_cracker007
  • 2,341
  • 1
  • 26
  • 26
0
votes
1 answer

How to mock or stub chmod method under FileUtils class in ruby

Hi guys I really need help on how to stub or mock a chmod method under FileUtils class in ruby. Currently I have this code. def create_file(file) unless File.exist?(file) FileUtils.mkdir_p(File.dirname(file), :mode => 0755) …
redwolfgang20
  • 368
  • 1
  • 5
  • 15
0
votes
2 answers

print text show the file path using Java

I need a java method to check text
0
votes
2 answers

Import org.apache.commons.io.FileUtils; not possible in latest apache poi.Instead import org.apache.tools.ant.util.FileUtils; is coming

In the latest Apache poi download(poi-3.15-beta2), while taking screenshot, I need to use FileUtils.copyFile. In its previous version, the imported package was import org.apache.commons.io.FileUtils;. In the latest download, this package is not…
0
votes
1 answer

How to copy a single folder with its contents to another folder in Java

I wrote this function below to find all folders named 'Construction Documents', I want it to copy all its contents over to another directory. private void findDirectory(File parentDirectory, String insertDir) { if(foundFolder) { …
ZKayyali
  • 23
  • 8
0
votes
2 answers

Android File.length() returns 0 while writing to it

I have a log file in my app that is constantly being written to and sometimes i need to check its size. The problem is that whenever i check its size quickly in another thread it sometimes returns 0, even though there is clearly data in it. For…
TychoTheTaco
  • 664
  • 1
  • 7
  • 28
0
votes
0 answers

parallel execution is not improving performance in Java-webapp

I have to download a bunch of files from a URL using Apache Commons -FileUtils.copyURLToFile in a Java web application through which multiple users accessing the webapp can download multiple files , tried in two ways sequential download for(each…
0
votes
0 answers

downloading a large file in java

here is my code for downloading a file from a webpage and saving it in a path: import java.io.File; import java.io.IOException; import java.net.URL; import org.apache.commons.io.FileUtils; public class Demo2 { public static void…
khalibali
  • 123
  • 1
  • 2
  • 16
0
votes
1 answer

Error: ';' expected comes when executing the programm

I have a small class that should allow me to rename and move some files and directories. Compilation gives me no syntax errors but when trying to execute, it freezes and I an error is displayed : Error: ';' expected - without specifying a line. My…
M. St.
  • 63
  • 6
0
votes
2 answers

how to know file name with extension from Remote FileInputStream in java

hi i have a FileInputStream which is pointing remote file in the server. how to know the filename and its extension which is pointed by this stream. if i want to write the remote file in my local computer, i have to know the file name and its…
0
votes
0 answers

SAAJ - Removing attachment from disk after sending message doesn't work

I'm adding a zip-file to a SoapMessage in an AttachmenPart and after the message has been send I'm trying to move the folder containing the xml-message and the zip-file to a history-Folder containing all the previously sent messages. However, this…
Daniel Wild
  • 167
  • 3
  • 7
0
votes
1 answer

Issue with org.apache.commons.io.FileUtils and Unix absolute/relative path

I am facing issue with absolute/relative path and org.apache.commons.io.FileUtils on Unix box. Issue is:- I am using cleanDirectory(..) and copyDirectory(..) of FileUtils. It works fine if I use absolute path /userName/data/feeds but gives…
SPS
  • 183
  • 1
  • 2
  • 10
0
votes
1 answer

Get all subdirectories matching a name

I am trying to get all subdirectories that have "messages_" in the name using FileUtils Collection filesToRead = FileUtils.listFiles(new File(fromDirectory), new DirectoryFileFilter() { @Override public boolean…
trailblazer
  • 1,421
  • 5
  • 20
  • 43
0
votes
1 answer

docx and xlsx files not being downloaded using HttpUrlConnection.getInputStream and FileUtils.copyInputStreamToFile

I'm trying to download a some files via webdav. I have some code which seems to work for all files except for Microsoft files. (e.g., docx, xlsx) By "work", I mean to say that I run the program, and I can find the file in the place that I…
user3337629
  • 181
  • 3
  • 9