class liste
{
int numara;
String ad;
String soyad;
liste sonraki;
}
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new FileReader("C:\\bagli.txt"));
BufferedReader reader = null;
String s;
Scanner klavye = new Scanner(System.in);
listeler mylist = new listeler();
while(br.ready())
{
s=br.readLine();
String[] firstLine = s.split("#");
liste kayıt = new liste();
kayıt.numara = Integer.parseInt(firstLine[0].trim());
kayıt.ad = firstLine[1].trim();
kayıt.soyad = firstLine[2].trim();
mylist.ekle(kayıt);
}
I get the following error
Exception in thread "main" java.lang.NumberFormatException: For input string: "33"
on the following line:
kayıt.numara = Integer.parseInt(firstLine[0].trim());
What should be the correct code ? bagli.txt in
33#ahmet#korkusuz 44#hanife#demir 66#murat#tok
listelerand why aren't you usingList<MyElement> list = new ArrayList<MyElement>();to store a list of elements?firstLine[0]has some non-printable character in it (since"33"can, of course, be parsed -- so there's something we can't see in the exception message). Use a debugger to single-step through the code to that line and see what exactly the string infirstLine[0]is, so you know what characters to remove from it.firstLine[0].trim()"33"with extra quotes and not just33without quotes.Exception in thread "main" java.lang.NumberFormatException: For input string: ""33""