Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at Random_Story_Generator.Reader(Random_Story_Generator.java:34)
at Random_Story_Generator.main(Random_Story_Generator.java:15)
Keep in mind, this program is far from complete, I just need help with this one thing. My text file is exactly 1403 words long, so that is the reason for the specific numbers.
import java.io.*;
import java.util.Random;
import java.lang.String;
public class Random_Story_Generator {
static String temp[] = new String[1403];
static int numbers[] = new int[1403];
static String words[][] = new String[1403][1403];
public static void main(String[] args) throws IOException {
Reader();
Creator();
}
public static void Random(){
int x = 0;
for(int y = 0; y < x; y++){
Random rndNumGen = new Random();
numbers[y] = rndNumGen.nextInt(1403);
}
}
public static void Reader() throws IOException, FileNotFoundException{
String line;
BufferedReader input;
input = new BufferedReader(new FileReader("H:\\RSGLyrics.txt"));
for(int c = 0; c < temp.length; c++){
line = input.readLine();
temp = line.split(" ");
}
for(int h = 0; h <= temp.length; h++){
System.out.print(" " + temp[h]); }
}
public static void Creator(){
int y = 0;
Random rndNumGen = new Random();
y = rndNumGen.nextInt(1403);
System.out.print(words[y]);
}
}










