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
61
votes
3 answers

Rails 5.2.0 with Ruby 2.5.1 console - `warning:` `already` initialized constant FileUtils::VERSION

I'm currently experiencing an issue with my new rails application, more specifically: Rails 5.2.0 Ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17] rvm 1.29.4 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin…
vchar
  • 956
  • 1
  • 11
  • 15
29
votes
1 answer

ruby copy folder with subfolders to a target location

I'm trying to copy a folder with all its subfolders from source to a destination folder. The below code doesn't seem to do it. I'm able to copy just the files instead of subfolders by using …
sasi
  • 289
  • 1
  • 3
  • 3
27
votes
7 answers

Using FileUtils in eclipse

When trying to use FileUtils I get "cannot be resolved" error. Then, how do I install FileUtils library to be able to use it in Eclipse? I see it is an Ant utility, but I am not sure how many jars I need to install.
prosseek
  • 182,215
  • 215
  • 566
  • 871
12
votes
3 answers

Java - Copy file to another directory using FileUtils and copyFileToDirectory - doesn't work -?

I would like to copy a file from one directory to another using Java and the FileUtils classes of apache org commons. I wrote up a quick java program to test on my local system. Here is the code. The file exists, but the copying of the file to…
katura
  • 2,177
  • 14
  • 39
  • 48
12
votes
2 answers

How can I recursively copy the directory contents and exclude the source directory itself?

Using FileUtils cp_r is usually how I copy directories, but I can't seem to exclude the base directory. This is what I wanted to work, but it doesn't: FileUtils.cp_r "#{source_path}\\**", target_path, :verbose => true source_path has…
George Horlacher
  • 191
  • 1
  • 3
  • 10
10
votes
2 answers

spring expression read file content

How to use spring expression to read file content and put it into a string? I would like to do the following. For example, @Value("classpath:myquery.sql") File f; @Value("#{org.apache.commons.io.FileUtils.readFileToString(f)}") String sql; Or even…
Timmy Chiu
  • 549
  • 4
  • 13
7
votes
2 answers

Java | Attempting to delete files on a Windows machine results in "phantom files"

I'm trying to delete some files on a windows machine using apache commons-io's FileUtils.deleteDirectory method (The version of the commons library is 2.4). Said method eventually calls the "forceDelete" FileUtils method which calls "file.delete()"…
7
votes
0 answers

Error : javax.net.ssl.SSLException: Connection reset (Specific Website only)

Kind Attn Moderators: Before marking this query as duplicate, please note I have checked these questions... java.net.SocketException: Connection reset What's causing my java.net.SocketException: Connection reset? Getting error…
iCoder
  • 1,406
  • 6
  • 16
  • 35
7
votes
1 answer

Ruby - FileUtils - dereference_root option

Can someone explain me exactly (better if with examples) the meaning of the dereference_root option in FileUtils.cp_r and in other class method of the same class? Thank you in advance.
Astorre
  • 75
  • 4
6
votes
1 answer

FileUtils.copyFile fails for large files

I have a simple Java app that is trying to copy a file across the WAN (from Ireland to NY). I recently modified it to use FileUtils because the native Java file copy was too slow. I researched and found that because Fileutils uses NIO it is better.…
Tony
  • 101
  • 1
  • 6
5
votes
1 answer

FileUtils copyURLToFile BasicAuthenication

How do I pass in user credentials for downloading files using apache commons FileUtils? I'm using an authenticator as below but doesn't seem to be working. It does not even complain about bad credentials so it looks like my authenicator is being…
Micho Rizo
  • 1,000
  • 3
  • 12
  • 27
5
votes
1 answer

FileUtils.copyFile() VS FileChannel.transferTo()

As I found, underlying OS call for the copyToFile() is Libcore.os.read(fd, bytes, byteOffset, byteCount), while transferTo() is based on memory mapped file: MemoryBlock.mmap(fd, alignment, size + offset, mapMode); ... buffer = map(MapMode.READ_ONLY,…
MobileX
  • 409
  • 4
  • 13
5
votes
2 answers

Parameter 'directory' is not a directory for a parameter which is a directory

I'm getting a strange error where the parameter I supply to a method complains that it's not a directory but it IS in fact a directory with files in it...I don't understand what's wrong... Toplevel: public static File mainSchemaFile = new…
mosawi
  • 1,283
  • 5
  • 25
  • 48
5
votes
1 answer

Creating directory over SFTP on Ruby fails if directory exists already

How can I create a directory on Ruby via SFTP only when the directory doesn't exist? I have the following code right now: Net::SFTP.start( ip, id, :password => pass, :port=> port ) do |sftp| sftp.mkdir! remotePath sftp.upload!(localPath +…
Laurice Llona
  • 97
  • 1
  • 8
5
votes
2 answers

Cannot delete zip file after unzipping?

I am facing an unusal issue.I am building a tool which is scheduled to run every 5 mins. It will pick up the zip files from a particular directory and extract files (depending on the file name) to a destination. I am using zipentry to get each…
1
2 3
15 16