java - String functions not working properly -
this program.it shouldnt print sentences starting word "ltp" or sentences containing word "trailing" ,but doesnt that..i dont understand why.please me this.
import java.io.*; public class fileinputdemo { public static void main(string args[]) { // args.length equivalent argc in c try { // open file first // command line parameter fileinputstream fstream = new fileinputstream( "c:\\documents , settings\\work\\desktop\\new folder\\new folder\\02apr2013log1.txt"); // convert our input stream // datainputstream datainputstream in = new datainputstream(fstream); // continue read lines while // there still left read while (in.available() != 0) { string s=in.readline(); // print file line screen if(s.startswith("ltp") || s.contains("trailing")) { continue; } system.out.println(in.readline()); } in.close(); } catch (exception e) { system.err.println("file input error"); } } }
and output
long trade managers in list (from limit removal process) 2 ltp 9708.0 current stop 9723.0 order id baa0001 mode:- trailing 9711.0 9716.0 9707.0 9707.0 9710.62 bullishfactor [openbullishfactor=neutral, closebullishfactor=bearish, closetoopenfactor=moderate_bearish] barsharing [sharingtype=lllh, bodysharing=0.44] ltp 9707.0 current stop 9717.0 order id baa0001 mode:- trailing
do not read line again in system.out.println(in.readline());
. read next line , not check if ltp | trailing available on line. replace system.out.println(s);
Comments
Post a Comment