Aaav VVB bb
Edc TGB ijb
-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Aaaa aaaa a
BBB bb bb
Cc CCC cc CCV
This TXT file, how to read only -- -- -- -- -- - the following
CodePudding user response:
Which master know?
CodePudding user response:
Have a Boolean flag=false,
The while loop, read lines, if it is -, flag=true,
If flag=true is processing data, not continue
CodePudding user response:
Judge!
Before the data is not stored at the back of the data storage is good
CodePudding user response:
How to judge, I wrote a few times always wrong
CodePudding user response:
reference 4 floor lanzhenhua response: how to judge, I wrote a few times always wrong Defining - add a state, the flag, when read into the bank after the flag to true, plus the if (flag) to add data CodePudding user response:
This program is what is wrong? List List=new ArrayList<> (a); A Boolean flag=false; String STR=br. ReadLine (); While (STR!=null) { If (STR. The contains (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")) flag=true; STR=br. ReadLine (); If (flag) { Xiaoliang xl=new xiaoliang (); String [] s=STR. The trim (). The split (" \ \ s + "); Xl. SetId (s [0]. ToString ()); Xl. SetZhongduan [1] (s); Xl. SetSps [2] (s); Xl. SetSjine [3] (s); Xl. SetQps (s [4]. The toString ()); Xl. SetQjine (s [5]. The toString ()); Xl. SetZhuangtai (s [6]. The toString ()); List. The add (xl); //slist. Add (s); //strB. Append (STR) append (" & lt; Br>" ); } } Br. The close (); //request. SetAttribute (" result ", message); Request. SetAttribute (" list ", a list); CodePudding user response:
refer to 6th floor lanzhenhua response: this program is what is wrong? List List=new ArrayList<> (a); A Boolean flag=false; String STR=br. ReadLine (); While (STR!=null) { If (STR. The contains (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ")) flag=true; STR=br. ReadLine (); If (flag) { Xiaoliang xl=new xiaoliang (); String [] s=STR. The trim (). The split (" \ \ s + "); Xl. SetId (s [0]. ToString ()); Xl. SetZhongduan [1] (s); Xl. SetSps [2] (s); Xl. SetSjine [3] (s); Xl. SetQps (s [4]. The toString ()); Xl. SetQjine (s [5]. The toString ()); Xl. SetZhuangtai (s [6]. The toString ()); List. The add (xl); //slist. Add (s); //strB. Append (STR) append (" & lt; Br>" ); } } Br. The close (); //request. SetAttribute (" result ", message); Request. SetAttribute (" list ", a list); you here "-- -- -- -- -- -- -- -- -- -- -- -- -- -- --" the length of the need and you are consistent in a text file, or less than, now look at you for example, a text file in the end, so use the contains is not found, returns false, the program does not perform