C
ChrisW
I'm trying to write a basic stats analysis program that analyses every
file in a folder. I can get a loop to go through the relevant files,
but I can't seem to use the current file name as an argument in the
File() method - I get a complile time error that basically says I need
a type string, not a type file:
This works:
for (int fileNumber = 0; fileNumber < listOfFiles.length; fileNumber+
+) {
if (listOfFiles[fileNumber].isFile()) {
System.out.println(listOfFiles[fileNumber]); //This prints the
current file name and does work
File dataFile = new File("file1.csv");
This doesn't work:
for (int fileNumber = 0; fileNumber < listOfFiles.length; fileNumber+
+) {
if (listOfFiles[fileNumber].isFile()) {
System.out.println(listOfFiles[fileNumber]); //This prints the
current file name and does work
File fileName = listOfFiles[fileNumber];
File dataFile = new File(fileName); //This doeesn't work
(I've also just tried File dataFile = new
File(listOfFiles[fileNumber]);
If anyone can throw any light on the problem I'd be most grateful
file in a folder. I can get a loop to go through the relevant files,
but I can't seem to use the current file name as an argument in the
File() method - I get a complile time error that basically says I need
a type string, not a type file:
This works:
for (int fileNumber = 0; fileNumber < listOfFiles.length; fileNumber+
+) {
if (listOfFiles[fileNumber].isFile()) {
System.out.println(listOfFiles[fileNumber]); //This prints the
current file name and does work
File dataFile = new File("file1.csv");
This doesn't work:
for (int fileNumber = 0; fileNumber < listOfFiles.length; fileNumber+
+) {
if (listOfFiles[fileNumber].isFile()) {
System.out.println(listOfFiles[fileNumber]); //This prints the
current file name and does work
File fileName = listOfFiles[fileNumber];
File dataFile = new File(fileName); //This doeesn't work
(I've also just tried File dataFile = new
File(listOfFiles[fileNumber]);
If anyone can throw any light on the problem I'd be most grateful