I will enhance an old algorithm which use java language and i want it to read the text from file to encrypt it SO I will make a method that reads the text line by line from file then store them in array. I made this method and it works BUT the variable "line2" reads the first line correctly but once the next line come it will erase the first line and put the second line so what can i do please??
// The CODES
Private byte[] line2;
public byte[] readFromFile (){
try (BufferedReader br = new BufferedReader(new FileReader ("C:\\Users\\just\\Desktop\\message.txt")))
{
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
line2 = sCurrentLine.getBytes();
}
} catch (IOException e) {
e.printStackTrace();
}
return line2;
}