I have the following code of a class used to read a file (.txt that contains 3 lines of 180 numbers each) and it runs perfectly. The problem is that as you may see I am just returning the array "data1", and I would like to return 3 arrays (data1,data2,data3) and 3 integer (total1,total2,total3) into the same method. Any ideas of how could i do it?. Thank you so much ;)!
public int [] OpenFile() throws IOException
{
FileReader reader = new FileReader(path);
BufferedReader textReader = new BufferedReader(reader);
int numberOfTimeZones = 3;
int[] data1 = new int[180];
int[] data2 = new int[180];
int[] data3 = new int[180];
int total1 = 0;
int total2 = 0;
int total3 = 0;
for (int i = 0; i < numberOfTimeZones; i++){
if (i == 0)
{
String firstTimeZone = textReader.readLine();
String[] val = firstTimeZone.split ("\\s+");
for (int u = 0; u < val.length; u++)
{
int stats = (int)(Math.ceil(Math.abs(Double.parseDouble(val[u]))));
total1 += stats;
total1= total1/180;
data1[u] = stats;
}
}
else
if (i == 1)
{
String secondTimeZone = textReader.readLine();
String[] val = secondTimeZone.split ("\\s+");
for (int u = 0; u < val.length; u++)
{
int stats = (int)(Math.ceil(Math.abs(Double.parseDouble(val[u]))));
total2 += stats;
total2= total2/180;
data2[u] = stats;
}
}
else
{
String thirdTimeZone = textReader.readLine();
String[] val = thirdTimeZone.split ("\\s+");
for (int u = 0; u < val.length; u++)
{
int stats = (int)(Math.ceil(Math.abs(Double.parseDouble(val[u]))));
total3 += stats;
total3= total3/180;
data3[u] = stats;
}
}
}
textReader.close();
return data1;
}
}