can anyone tell me the right approach for filling an array from a text file?
Here is the code I am working with. This code is successfully displaying the contents of the file to screen.
I am trying to get the contents of the file and fill the int aTerm array
import java.io.*;
public class CheckFile
{
public static void main(String[] args) throws IOException
{
String sFileName = "Week4_Data.txt";
File years = new File(sFileName);
InputStream iStream;
OutputStream oStream;
int c;
iStream = new FileInputStream(years);
oStream = System.out;
int aTerm [] = {0,0,0};
try
{
while((c=iStream.read()) != -1)
oStream.write(c);
}
catch(IOException e)
{
System.out.println("Error: " + e.getMessage());
}
finally
{
iStream.close();
oStream.close();
}
}
}