Hi
I've already read data in another file which is an array, which is now in a string format, what I want to do is change the array into an integer so that I can add the elements of that array.
Code given below
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
/*
* @author kagisoboikanyo
*/
public class ReadInput {
public static void main(String[] args) throws FileNotFoundException, IOException {
try{
FileInputStream fstream = new FileInputStream("superIncrease.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
in.close();
}
catch (Exception e){
System.err.println("Error:" +e.getMessage());
}
}
//System.out.println("Test: " + knapsack.toString());
}
As I said earlier I am able to view the elements which is an array, but its in a string format now what I need to do is change it to an integer then add the elemnts together to find a sum.
Thanks in advance.