I need to split the below string:
line.long 0x0 " MIDR, Identity Code Register"


I have used space , as the delimiters.

the code should give output in such a way that

Command Name: line
Size: long
Offset : 0x0
short name: MIDR
Long name=Identity code register.


The problem is since i have used space as a delimiter. i need a code in such a way that it should not consider space as a delimiter while splittin the string inside a " " quotes..


can any one help me please..

if (strLine.startsWith("line"))
				{
					
					strLine = strLine.substring(0, (strLine.length()-1));
					
						String[] stringSplit = strLine.split("['. ,']");
						
						
						System.out.println("Command Name: "+stringSplit[0].trim());
						System.out.println("Size: "+stringSplit[1].trim());
						System.out.println("Offset : "+stringSplit[2].trim());
				
													
						System.out.println("Short Name : "+stringSplit[3].trim());
						System.out.println("Long Name : "+stringSplit[4].trim()+stringSplit[5].trim());
						carCount = 1;
						linecount = 0;
					
				}

normally, I don't think you can't 'switch' from delimiters while splitting the String already, but, if the part between "'s is the last part of your inputstring, you could first split the original String using the indexOf and substring methods of the String class, so you would have as original Strings:
String one = "line.long 0x0";
String two = "\" MIDR, Identity Code Register\"" ;

Actually i am reading from a txt file.. it contains of thousand of line.. one line will start from 2 blanks ,another line will start from 3 blank spaces.. how to eliminate this starting blank spaces.. iam using trim().. but iam not able to eliminate blank spaces..

read the line, and first, run a method that removes the first characters (if they are spaces)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.