Tried for a long time, or not use String.matches (String regx)

Category: Java SE
 
YY19868231987527
2012-09-19 08:18:28

Sponsored Links
My request is actually very simple
I always loop until the server reads the feedback "220 ftp server ready ..." This sentence

while (true) {
s = reader.readLine (); / / reader is to read the server function of the feedback information
if (s.matches ("220")) {
; System.out.println ("read the server's welcome message:" + s);
break;
}
}
has not read

So I simply

s = String ("220 server ready");
if ( s.matches ("220")) {
System.out.println ("220 was read!")
}

is still not.

Sponsored Links

akvip6
2012-09-19 08:28:05
String has this way?
string comparison Why not equals (), compareTo ()
and indexOf (), etc.
zhu1_zhu1
2012-09-19 08:33:47
1.4 in which there is this method.

because I'm afraid some of the ftp server does not start with 220, and other places slightly more complex but also to use other functions, or use regular expressions better.

fact summarize, my request is very simple, is to determine whether there is a String inside a subString.
xktrouble
2012-09-19 08:51:35
that use
String par;
String sub ;/ / substring

if (par.indexOf (sub)> = 0)
/ / do what you want
tjkevin1
2012-09-19 09:04:24
hey, oh well!

knot posted.
yinga
2012-09-19 09:17:00
matches a match
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.