Code
package com.ferfykins.exercises;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
String path = "/home/ferfykins273/Desktop/MyJavaCode/Github exercises/EncryptDecrypt/info.txt";
readFile(path);
}
public static String[] readFile(String path) {
String line;
String[] data[] = null;
try (BufferedReader br = new BufferedReader(new FileReader(path))) {
while ((line = br.readLine()) != null) {
data = line.split(" ");
for(String stuff : data) {
System.out.print(stuff + " ");
}
System.out.println();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return data;
}
}
So as you can see there are plenty of errors, just not sure how to fix them.
Basically what i wanna do is read a text file, and put all the contents into an array, and return that array , so i can use it in different methods.....