This is my code to download and read the text in my file in Dropbox. Version is a URL.
BufferedReader in = new BufferedReader(new InputStreamReader(version.openStream()));
String inputLine;
int line = 0;
try{
while ((inputLine = in.readLine()) != null){
strings[line] = new String(inputLine);
line++;
}
} catch (Exception e){
e.printStackTrace();
}
Although, I get this really annoying error.
java.lang.ArrayIndexOutOfBoundsException: 1
at sky.the.venture.client.Download.getCredits(Download.java:38)
at sky.the.venture.client.LauncherFrame.credits(LauncherFrame.java:315)
at sky.the.venture.client.LauncherFrame.(LauncherFrame.java:49)
at sky.the.venture.Destiny.(Destiny.java:13)
at Start.main(Start.java:11)
So, the part which is an error is Download.java:38. Which is
strings[line] = new String(inputLine);
So if anyone can help, I will be really happy =D
Well presumably you only created an array like this:
Arrays don’t resize themselves in Java – indeed, they can’t be resized. If you want a dynamically sized collection, use a
List<E>implementation e.g.ArrayList<E>: