String.matches is not in jdk 1.3, use String.indexOf instead

This commit is contained in:
Doug MacEachern 2004-11-15 00:54:53 +00:00
parent 15a5fb329e
commit a44e55ab6a
1 changed files with 9 additions and 3 deletions

View File

@ -27,6 +27,12 @@ public class SysInfo extends SigarCommandBase {
return "Display system information"; return "Display system information";
} }
private static boolean contains(String value, String substr) {
//matches does not work w/ jre 1.3
//value.toLowerCase().matches(".*" + substr + ".*");
return value.toLowerCase().indexOf(substr) != -1;
}
public void output(String[] args) throws SigarException { public void output(String[] args) throws SigarException {
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
@ -46,10 +52,10 @@ public class SysInfo extends SigarCommandBase {
{ {
public boolean accept(File dir, String name) public boolean accept(File dir, String name)
{ {
boolean distroFile = boolean distroFile = contains(name, "elease");
name.toLowerCase().matches(".*elease.*");
if (!distroFile) { if (!distroFile) {
distroFile = name.toLowerCase().matches(".*ersion.*"); distroFile = contains(name, "ersion");
} }
return distroFile; return distroFile;
} }