Hi all ..
I've been doing my coursework ..
I have done 30% of it ..
but I've met problem since the day before yesterday ..
I've tried to solve it but I couldn't ..
I've been requested to write programme that promote the user to enter a file name then it will be read ..
the problem that I've got is when the file is being read then copied to a String I always get ?? ( two question mark s) just in the index [0][0] after printing it .. !!
but all the other outputs are correct ..
NOTE: I've not write the Exceptions yet .. I will do when every thing work ..
this is my code ..
import java.io.*;
class StudentMarks{
public static void main(String[] args) throws Exception {
// local variables
String FileName, Read, ID, M, Marks;
String [][] str1 = new String [500][3];
System.out.println("Enter the File name: ");
FileName = UserInput.readString();
File fis = new File(FileName);
BufferedReader file = new BufferedReader(new FileReader(fis));
for (int x = 0; (Read =file.readLine())!= null ; x++) {
// the ID, M and Marks will be initialized to null
ID = null;
M = null;
Marks = null;
String[] str2 = replace.split(","); // here str2 contains {ID, M, Marks}
ID = str2[0]; // ID will be set in index 0 in str2
M = str2[1]; // M will be set in index 1 in str2
Marks = str2[2]; // Marks will be set in index 2 in str2
str1[x][0] = ID; // ID will always be set in index[x][0] in str1
str1[x][1] = M; // M will always be set in index [x][1] in str1
str1[x][2] = Marks; // Marks will always be set in index [x][2]in str1
} // end of for
file.close();
System.out.println(str1[0][0]);
System.out.println("----");
} // end of main
} // end of class
the output that I get is
Enter the File name:
marks.csv
??acc09u
----
I don't know why questions marks .. !! there is no questions marks in marks.csv file ..
I also try to use
str[0][0].equals(str[1][0])
to compare between 2 variables in the dimensional arrays .. it's compiled correctly but the output is wrong .. !!
could you please give me an explanation before the answer so I can understand the reason of these 2 problems and understand what I'm doing because I have to write report about that .. ^_^
Thanks in advance .. =)