java - How to get rid of text at the start of a string? -
i have text file, , starts off text before getting data need program. how go getting rid of text , pick data behind it?
the file reads so:
text text text text text text text text 2010 1 0.00 0.00 0.00
i'd totally skip text , straight data starts 2010
.
my current way of reading text file , sorting array using scanner()
so:
public void readfile(){ int = 0; int j = 0; int k = 0; while(rainfile.hasnext()){ string = rainfile.next(); sorteddata[i][j][k] = a; k++; if(k==31){ j++; k=0; if(j==12){ i++; j=0; } } } }
my array being sorted fine, short of manually deleting text @ start of file don't know how exclude it.
thanks in advance.
you can use string#indexof(string str) method find first occurence of 2010. example:
string text = "text text text text text text text text 2010 1 0.00 0.00 0.00"; string start = text.substring(text.indexof("2010")); system.out.println(start);
this piece of code give output 2010 1 0.00 0.00 0.00
.
Comments
Post a Comment