Questions tagged [apache-commons-io]

Apache Commons IO is a library of utilities to assist with developing IO functionality.

Apache Commons Commons IO is a library of utilities to assist with developing IO functionality.

There are six main areas included:

  • Utility classes - with static methods to perform common tasks
  • Input - useful Input Stream and Reader implementations
  • Output - useful Output Stream and Writer implementations
  • Filters - various implementations of file filters
  • Comparators - various implementations of java.util.Comparator for files
  • File Monitor - a component for monitoring file system events

Official Website: http://commons.apache.org/io/

Useful Links:

Related Tags:

175 questions
3
votes
1 answer

Does CF not support Java constructors with variable number of arguments and any known workarounds?

We have a project that deals with files of various encodings. I am using BOMInputStream to skip UTF-8 byte order markers. The existing code works but needs to also support UTF-16 variations. The most straight forward approach is to pass the…
Dan Roberts
  • 4,455
  • 2
  • 31
  • 42
3
votes
3 answers

Socket stream hangs when using IOUtils.copy()

I want to send an InputStream containing XML from the client to a server. Said server manipulates the XML stream using Streaming API for XML (StAX) and sends it back to the client. I mange to send the XML to the server, the client receives the…
shypy
  • 51
  • 1
  • 4
3
votes
1 answer

What is the benefit of having synchronized an InputStream?

I recently used Apache Commons-IO's class CountingInputStream. It just keeps track how many bytes were read by updating a counter field. I noticed that it updates its counter with the synchronized keyword. The best source that I could find is…
Markus Malkusch
  • 7,201
  • 35
  • 61
3
votes
2 answers

Error while uploading the file on the server

My web app is made on Spring MVC. I have a feature where the user can change his/her profile picture. The I am sending the file as mutlipart file to the server. Every time the user uploads the picture, the name of the file is kept same. First time…
warrior107
  • 539
  • 1
  • 7
  • 23
3
votes
1 answer

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

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.…
Stealth Rabbi
  • 9,370
  • 17
  • 89
  • 161
3
votes
2 answers

IOUtils.copy() hangs when copying big stream?

I want to parse content of some file by srcML parser which is an external windows program. I'm doing this in a following way: String command = "src2srcml.exe --language java"; Process proc = Runtime.getRuntime().exec(command); InputStream…
Kao
  • 6,619
  • 7
  • 39
  • 64
3
votes
2 answers

FileUtils.listFiles() on resources directory

In my project I have a resources directory with a my_directory inside. my_directory contains text files. I want to loop this directory with: URL resource = Resources.class.getResource("/my_directory"); File directory = new…
hsz
  • 136,835
  • 55
  • 236
  • 297
3
votes
1 answer

java.util.zip.ZipException: invalid stored block lengths

I am trying to read a ZipArchiveEntry to String. I have the below code and i run into exception My code is as below StringWriter writer = new StringWriter(); IOUtils.copy(zipFile.getInputStream(zipArchiveEntry), writer, …
Vinod Jayachandran
  • 3,208
  • 5
  • 31
  • 64
3
votes
1 answer

How to continue copying on error with copyDirectory from FileUtils (Apache Commons IO 2.4)

I am trying to copy files from one folder to another using the FileUtils method "static void copyDirectory(File srcDir, File destDir)" from apache commons io (2.4) with the following code: String srcDir = "/sourceDirectory/examples/"; String…
Exocom
  • 751
  • 2
  • 8
  • 22
3
votes
1 answer

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

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…
developer
  • 9,003
  • 29
  • 80
  • 144
2
votes
1 answer

Maven Shade overlapping classes warning

I am using commons-io in my project and want to shade it. I am running into a warning that I can't seem to figure out: [WARNING] commons-io-2.7.jar, murder-1.0-SNAPSHOT.jar define 180 overlapping classes and resources: ... I find this strange, as…
Vapid Linus
  • 555
  • 3
  • 21
2
votes
0 answers

in java apache.commons.io,how to avoid to read the old log messages

i am using the java Tail-listener API to do the tailf function(in Linux).ie,whenever log messages are updated in log file, this API will print the messages. My code is given below. public static void main(String[] args) { // TODO code…
ssbecse
  • 61
  • 4
2
votes
1 answer

Apache Commons IO download only first PDF page

I'm using Java with Apache Commons-IO to download a PDF but I only want to get the first page, is there a way I can do it? Here's the piece of code that gets the whole doc: public void getPDF(String route) throws IOException { URL url = new…
2
votes
4 answers

Exclude File Filter

I used the following code to filter files that are having the following extension FileFilter fileFilter= new WildcardFileFilter("*.docx"); File[] sampleFiles= filesDirectory.listFiles(fileFilter); But what if I want the opposite, I want to exclude…
Mark Estrada
  • 8,275
  • 34
  • 107
  • 173
2
votes
0 answers

Fastest way to convert Input Stream to a String in java

There are many different ways to convert an inputStream to a String in java example Guava, Apache Commons IO and plain java like scanner class and ByteOutputStream. There are a lot of websites and question on stack overflow that show you how to do…
user7331538
  • 1,258
  • 1
  • 9
  • 31
1 2
3
11 12