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
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
  • 519
  • 2
  • 9
  • 28
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
  • 319
  • 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,225
  • 1
  • 16
  • 40
2
votes
1 answer

org.apache.commons.io.FileUtils - change text encodig

I have one file which contains text(ukranian symbols). Example: ${name} - привіт. I need to replace from ${name} to Саша. But in output file I recive something like this: пÑ??Ð¸Ð²ÐµÑ - привіт instead of Саша- привіт. But if I use .txt instead .rtf…
Alex85
  • 135
  • 1
  • 3
  • 10
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,299
  • 3
  • 28
  • 46
2
votes
2 answers

How to get all subdirectories excluding some subdirectories?

I have a list of directories that I'm using in a selectMenu in a webpage. The list contains all sub-directories under a certain directory, retrieved using the below java code.. File directory = new File("C:\\myHomeDirectory"); myDirectories =…
Fati
  • 57
  • 1
  • 7
2
votes
2 answers

How to download a pdf file programmatically from a webpage with .html extension?

I have reviewed ALL similar questions (not only this!) on this forum and have tried ALL of those methods however still was not able to programmatically download a test file: http://pdfobject.com/markup/examples/full-browser-window.html The following…
CHEBURASHKA
  • 1,623
  • 11
  • 53
  • 85
2
votes
4 answers

How to save a .pdf from a browser?

I tried to save .pdf file using different methods I found on stackoverflow including FileUtils IO, however, I would always get it damaged. As I opened the damaged file using a notepad I got the following stuff: …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/selenium" class="post-tag grid--cell" title="show questions tagged 'selenium'" rel="tag">selenium</a> <a href="../../questions/tagged/io" class="post-tag grid--cell" title="show questions tagged 'io'" rel="tag">io</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 27 '13 at 20:44">asked Sep 27 '13 at 20:44</time> <a href="../../users/2088905/buras" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2088905.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Buras" /> </a> <div class="s-user-card--info"> <a href="../../users/2088905/buras" class="s-user-card--link">Buras</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">3,069</li> <li class="s-award-bling s-award-bling__gold" title="28 gold badges">28</li> <li class="s-award-bling s-award-bling__silver" title="79 silver badges">79</li> <li class="s-award-bling s-award-bling__bronze" title="126 bronze badges">126</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-17739565"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>2</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/17739565/how-to-handle-errors-from-fileutils-cd" class="question-hyperlink">How to handle errors from Fileutils cd</a></h3> <div class="excerpt">I'm having troubles when using Fileutils method in ruby When using: FileUtils.cd("A/non/existing/directory") I get an error output as expected but my ruby script violently ends. Question is how can I prevent my ruby script from stopping when I try…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/ruby" class="post-tag grid--cell" title="show questions tagged 'ruby'" rel="tag">ruby</a> <a href="../../questions/tagged/methods" class="post-tag grid--cell" title="show questions tagged 'methods'" rel="tag">methods</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 19 '13 at 06:38">asked Jul 19 '13 at 06:38</time> <a href="../../users/2585703/pass" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2585703.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Pass" /> </a> <div class="s-user-card--info"> <a href="../../users/2585703/pass" class="s-user-card--link">Pass</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">23</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-11836867"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>2</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>4</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/11836867/recursively-delete-a-folder-in-java" class="question-hyperlink">recursively delete a folder in java</a></h3> <div class="excerpt">I already have a code that works, but I don't want it to actually delete the temp folder if possible. I am using the apache fileutils. Also does anyone know how to exclude folders from being deleted? public class Cleartemp { static String…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Aug 06 '12 at 22:26">asked Aug 06 '12 at 22:26</time> <a href="../../users/1454847/jerhynsoen" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1454847.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="jerhynsoen" /> </a> <div class="s-user-card--info"> <a href="../../users/1454847/jerhynsoen" class="s-user-card--link">jerhynsoen</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">205</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="7 silver badge">7</li> <li class="s-award-bling s-award-bling__bronze" title="20 bronze badge">20</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-11647802"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>2</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>0</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/11647802/difference-between-du-command-and-apache-fileutils-sizeofdirectory" class="question-hyperlink">difference between du command and apache FileUtils.sizeOfDirectory</a></h3> <div class="excerpt">I do a simple du -sh on /etc/ directory it shows me 11M. But when I use: System.out.println(FileUtils.byteCountToDisplaySize(FileUtils.sizeOfDirectory(new File("/etc/")))); This shows me: 68 MB. Is this bug? Or I'm missing something. [UPDATE] When…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/du" class="post-tag grid--cell" title="show questions tagged 'du'" rel="tag">du</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 25 '12 at 10:33">asked Jul 25 '12 at 10:33</time> <a href="../../users/654269/majid-azimi" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/654269.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Majid Azimi" /> </a> <div class="s-user-card--info"> <a href="../../users/654269/majid-azimi" class="s-user-card--link">Majid Azimi</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">5,575</li> <li class="s-award-bling s-award-bling__gold" title="13 gold badges">13</li> <li class="s-award-bling s-award-bling__silver" title="64 silver badges">64</li> <li class="s-award-bling s-award-bling__bronze" title="113 bronze badges">113</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-11551362"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>2</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/11551362/cannot-run-fileutils-copy-because-i-m-receiving-an-error-when-i-require-fileut" class="question-hyperlink">Cannot run FileUtils.copy because I'm receiving an error when I require 'fileutils.rb'</a></h3> <div class="excerpt">I am receiving the following error when running my code below /Users/Castillo/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/fileutils.rb:1423:in stat': No such file or directory - file.txt (Errno::ENOENT) from…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/ruby" class="post-tag grid--cell" title="show questions tagged 'ruby'" rel="tag">ruby</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 18 '12 at 22:34">asked Jul 18 '12 at 22:34</time> <a href="../../users/1427457/smooth" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1427457.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Smooth" /> </a> <div class="s-user-card--info"> <a href="../../users/1427457/smooth" class="s-user-card--link">Smooth</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">956</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="15 silver badge">15</li> <li class="s-award-bling s-award-bling__bronze" title="37 bronze badge">37</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-10111372"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>2</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/10111372/do-the-methods-in-apache-s-fileutils-peform-synchronous-blocking-i-o" class="question-hyperlink">Do the methods in Apache's FileUtils peform synchronous (blocking) i/o?</a></h3> <div class="excerpt">Do the methods in Apache's FileUtils perform synchronous (blocking) i/o? I am making a call to FileUtils.copyDirectoryToDirectory. In my next line, I want to delete the directory that I copied. Example: FileUtils.copyDirectoryToDirectory(source,…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/synchronous" class="post-tag grid--cell" title="show questions tagged 'synchronous'" rel="tag">synchronous</a> <a href="../../questions/tagged/java-io" class="post-tag grid--cell" title="show questions tagged 'java-io'" rel="tag">java-io</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 11 '12 at 17:57">asked Apr 11 '12 at 17:57</time> <a href="../../users/94523/h-bomb" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/94523.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="h-bomb" /> </a> <div class="s-user-card--info"> <a href="../../users/94523/h-bomb" class="s-user-card--link">h-bomb</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">366</li> <li class="s-award-bling s-award-bling__silver" title="5 silver badges">5</li> <li class="s-award-bling s-award-bling__bronze" title="17 bronze badges">17</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-70187049"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/70187049/fileutils-write-method-does-not-work-on-azure-databricks" class="question-hyperlink">FileUtils write method does not work on Azure Databricks</a></h3> <div class="excerpt">I have troubles writing a file on my Databricks cluster's driver (as a temp file). I have a scala notebook on my company's Azure Databricks which contains those lines of code : val xml: String = Controller.requestTo(url) val bytes: Array[Byte] =…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/azure" class="post-tag grid--cell" title="show questions tagged 'azure'" rel="tag">azure</a> <a href="../../questions/tagged/scala" class="post-tag grid--cell" title="show questions tagged 'scala'" rel="tag">scala</a> <a href="../../questions/tagged/databricks" class="post-tag grid--cell" title="show questions tagged 'databricks'" rel="tag">databricks</a> <a href="../../questions/tagged/azure-databricks" class="post-tag grid--cell" title="show questions tagged 'azure-databricks'" rel="tag">azure-databricks</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 01 '21 at 15:36">asked Dec 01 '21 at 15:36</time> <a href="../../users/12873652/karzyfox" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/12873652.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Karzyfox" /> </a> <div class="s-user-card--info"> <a href="../../users/12873652/karzyfox" class="s-user-card--link">Karzyfox</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">319</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badge">2</li> <li class="s-award-bling s-award-bling__bronze" title="15 bronze badge">15</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-68379408"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>1</strong></span> <div class="viewcount">vote</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/68379408/attributeerror-module-utils-has-no-attribute-read" class="question-hyperlink">AttributeError: module 'utils' has no attribute 'read'</a></h3> <div class="excerpt">I'm trying to train a model using PyTorch and I got this error AttributeError: module 'utils' has no attribute 'read' In the main project I have the file utils.pyx and also I'm getting an error in this particular line for i, data in…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/pytorch" class="post-tag grid--cell" title="show questions tagged 'pytorch'" rel="tag">pytorch</a> <a href="../../questions/tagged/generative-adversarial-network" class="post-tag grid--cell" title="show questions tagged 'generative-adversarial-network'" rel="tag">generative-adversarial-network</a> <a href="../../questions/tagged/fileutils" class="post-tag grid--cell" title="show questions tagged 'fileutils'" rel="tag">fileutils</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jul 14 '21 at 13:53">asked Jul 14 '21 at 13:53</time> <a href="../../users/16398081/ttt" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/16398081.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="TTT" /> </a> <div class="s-user-card--info"> <a href="../../users/16398081/ttt" class="s-user-card--link">TTT</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">11</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badge">1</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badge">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/fileutils_page=3" rel="prev" title="Go to page 3">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/fileutils_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/fileutils_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/fileutils_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/fileutils_page=15" rel="" title="Go to page 15">15</a> <a class="s-pagination--item" href="../../questions/tagged/fileutils_page=16" rel="" title="Go to page 16">16</a> <a class="s-pagination--item" href="../../questions/tagged/fileutils_page=5" rel="next" title="Go to page 5"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>