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

221 questions
2
votes
1 answer

file.delete() returning false even file is writable

I'am trying to copy a file to a directory and then deleting it, but file.delete() keeps returning false Here is my code: for (File file : list) { if (!file.isDirectory()) { try { …
Vithor Escames
  • 96
  • 2
  • 13
2
votes
2 answers

Java - How to move files using FileUtils?

Everyone keeps saying how simple it is to move a file from point a to point b using fileutils, but I'm having lots of trouble moving a file :( I have a /temp/ folder in the directory wherever the .jar is located, in this temp folder I have a .txt…
peterxz
  • 750
  • 5
  • 16
2
votes
0 answers

apache common io fileUtils listFiles: how to get list of files with no extension?

I am trying to get a list of files with no extension using org.apache.commons.io.FileUtils.listFiles() like…
Alexander
  • 51
  • 1
  • 4
2
votes
1 answer

Java FileNotFoundException with Absolute path - Cant Read or Execute, but file exists

I'm sure this has been answered, but ten different strategies hasn't worked on this issue. If I use C:\Users\Anny\Dropbox\SocialMediaOcto\instructions\Trees\instructions.txt as my absolute path for the file, IDEA cannot read or execute from…
Jayizzle
  • 492
  • 1
  • 6
  • 20
2
votes
1 answer

java - Progress Bar while download with FileUtils

I'm trying to download a large file from URL with commons.io Apache library. This is my code: InputStream stream = new URL(CLIENT_URL).openStream(); ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, "Downloading...",…
luca89pe
  • 77
  • 1
  • 11
2
votes
1 answer

Waiting for File Lock to Be Released

There are some Java questions similar to this one but none of them had accepted answers that I could find and my situation is a little more specific. I have a program that processes files one at a time as they are fed into a directory. At times,…
Pablo Vadear
  • 95
  • 10
2
votes
1 answer

ruby - Permission denied after File.open and rename

I modify a file and then try to rename it and rename his directory. But I get a permission denied error. Here is my code : # 1) Modify the xml file Xml_file = "Directory/foo.xml" begin contents = File.new(Xml_file).read $document =…
2
votes
1 answer

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,175
  • 4
  • 18
  • 43
2
votes
1 answer

create temp file using utils in java not using : java.io.File.createTempFile()

Currently I am using java.io.File.createTempFile() to create a temp file. But it has a validation to filter out those file names which is less than 3 words. Like this if (prefix.length() < 3) throw new IllegalArgumentException("Prefix string too…
user5070277
2
votes
3 answers

How to replace a string in an xml file without loading file contents into memory in java?

My application creates a very big xml file (of about 300K transactions). Each of the transaction will have about 20 xml elements. So it creates a huge xml file. We did not use JAXB or SAX or DOM for creation of xml file as memory is the constraint.…
2
votes
0 answers

getWritablePath() in cocos2d-x on Windows Phone gives weird results

I'm trying to get the writable path on Windows Phone in my game but CCFileUtils::sharedFileUtils()->getWritablePath() always returns me results like "H??", "???", "??y". I've already tried using this on cocos2d-x v2 and v3 with no luck. Also I have…
maksg
  • 21
  • 2
2
votes
1 answer

Trying to download a file using FileUtils

I'm using this atm: package com.obisdian.downloader; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.URL; import org.apache.commons.io.FileUtils; /** * Downloads the…
Kiraged
  • 491
  • 1
  • 9
  • 27
2
votes
2 answers

Is it possible for Java's FileVisitor.visitFile() to be called on a nonexistent file?

Java's java.nio.file.Files.walkFileTree() executes the visitor's visitFile() method even if a file doesn't exist (a recently-deleted file). FileUtils.forceDelete(certainFile); Files.exists(certainFile.toPath()); // Returns false, as…
Andrew Liu
  • 309
  • 1
  • 2
  • 13
2
votes
1 answer

How to change the file/folder permission programmatically in android

I want to change the permission of a folder were application database is being stored. After searching on Google I found this:- public int chmod(File path, int mode) throws Exception { Class fileUtils = Class.forName("android.os.FileUtils"); …
Amit Anand
  • 1,181
  • 15
  • 39
2
votes
0 answers

Apache Commons FileUtil tool not returning true on equal file compare

I am trying to compare two txt files using Apache Commons FileUtil tool. Here's my code: if (entity.isDirectory()){ File[] listOfFiles = entity.listFiles(); for (File file : listOfFiles){ try { …
kajarigd
  • 1,261
  • 3
  • 25
  • 41
1 2
3
14 15