I am trying to read a rectangle.csv
file in Java. But while I was reading the file and assigning to a string array, the first element is reading some garbage value along with the first element.
package sample;
import java.io.BufferedReader;
import java.io.FileReader;
import java.time.LocalDateTime;
public class rectangleDemo {
private static Rectangle[] rect ;
private static int count;
static private void loadFile( String filepath)
{
try { // Try catch expression to catch exception
String info=" ";
BufferedReader reader =null;
reader = new BufferedReader(new FileReader(filepath));
while ((info = reader.readLine()) != null)
{
String temp[] = info.split(",");
//
System.out.println(temp[0]);
System.out.println(temp[1]);
}
System.out.println("Database loaded successfully!");
reader.close();
}
catch (Exception e)
{
e.printStackTrace(System.out);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
loadFile("rectangle.txt");
}