-1

I have a text file which saves my staff details, I want to store the id for future use after login.

I've tried declaring the id after login as split[0] but when i call it, it returns null.

This is within the login method in the file TypoStaff

String id = split[0];

This is my method of calling

TypoStaff s = new TypoStaff();
System.out.println(s.id);

I hope to get the result of 0 but I keep getting null.

Bharti Rawat
  • 1,949
  • 21
  • 32
Reon Low Yiyuan
  • 123
  • 2
  • 2
  • 10

1 Answers1

0

I don't know that how you split string. You can try this. this is working.

String s = "0|NAME|USERNAME|EMAIL|PASSWORD";
String[] cp=s.split("\\|");
System.out.println(cp[0]);
Rowi
  • 545
  • 3
  • 9