I am passing a list of file names to another object and having problems.
The hard coded version works and looks like this. We are passing jpegFile to another object and its processed correctly with the following code.
As you can see the object receiving jpegFile expects List<string>
The above code works good. However what I really need to do is read in the file names from a directory.
That part is also working with the code below.
Is there a way to convert jpgFiles from a File object to a List, or String?
I can do:
String TestString = jpgFiles.toString...however I would like to convert more than 1 index at a time.
I have tried quite a few things...and keep getting Cannot convert...errors. It needs to be formatted the same as in the first code example. Can someone show me how to do this?
I also did:
And it worked good...Only problem was it only returned the filename...and I need the full path as it's returned as a File.
Once you list files with the given file filter (suppose WildcardFileFilter is from org.apache.commons.io.filefilter), you get array of File objects. One solution might be to initialize String array based on the length of that File array; in your case JPEG_FILES to be of size jpegFiles.length. Then you can use for loop to populate JPEG_FILES array with Strings, where each String represents path to the file by using getCanonicalPath() method of File class.
The quieter you are, the more you are able to hear.