I have tried split with some other texts, its working fine there but not here. Can someone tell me what I did wrong here?
private static String fileName = "jjjj.txt";
private static String userName = "xxxx";
private static String password = "yyyy";
public static void main(String args[]){
String info = "UserName" +"|"+ userName + "|" + password + "|" + fileName;
String tempStr[] = info.split("|");
System.out.println(tempStr[0]);
System.out.println(tempStr[1]);
System.out.println(tempStr[2]);
System.out.println(tempStr[3]);
}
I am getting output as :
U
s
e
What should I do to get the output as:
UserName
xxxx
yyyy
jjjj.txt