I've written code to copy the file paths of a number of files in a directory into an array.
I now want to take the array of file paths and loop through them one at a time and apply each file path to a FileInputStream within a BufferedReader (so that each file is opened and processed individually and closed).
Is there a general way to go about doing that? It seems a for loop would work, but what about Scanner to scan the array line by line?
When you say that you have copied the file paths, do you mean that you have an array of string and you have copied the file paths into there? Where are you getting these paths from? Are you just scanning a directory? If so, you would generally use File.listFiles and a for() loop.
Why don't you increment i inside the for statement?
It is hard to say what your code does (because you posted very little code).
And you forgot to put a semicolon after i++.
And try to indent it correctly so it is more readable.
Here is my full code. This code returns all of the data from the files I am wishing to process, however the formatter prints each line of data subsequntly, instead of processing one file, returning the file strings of data (H2OIN, CO2IN, etc) then moving to the next file.
I wish to process and extract the file name and five strings of data from each file, write the information to the output text file, then move to the next file path. When I test the writer with a single input file, the data outputs in the proper format.
Post by:autobot
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
a bit of art, as a gift, that will fit in a stocking