Skip to content

Instantly share code, notes, and snippets.

@elek
Created March 9, 2012 14:56
Show Gist options
  • Save elek/2006855 to your computer and use it in GitHub Desktop.
Save elek/2006855 to your computer and use it in GitHub Desktop.
Daily WTF from javax.comm.jar
//from javax.comm.jar
private static String findPropFile()
{
String str1 = System.getProperty("java.class.path");
StreamTokenizer localStreamTokenizer = new StreamTokenizer(new StringReader(str1));
localStreamTokenizer.whitespaceChars(File.pathSeparatorChar, File.pathSeparatorChar);
localStreamTokenizer.wordChars(File.separatorChar, File.separatorChar);
localStreamTokenizer.ordinaryChar(46);
localStreamTokenizer.wordChars(46, 46);
try
{
while (localStreamTokenizer.nextToken() != -1)
{
int i = -1;
if ((localStreamTokenizer.ttype != -3) ||
((i = localStreamTokenizer.sval.indexOf("comm.jar")) == -1))
continue;
String str2 = new String(localStreamTokenizer.sval);
File localFile = new File(str2);
if (localFile.exists()) {
String str3 = str2.substring(0, i);
if (str3 != null) {
str3 = str3 + "." + File.separator + "javax.comm.properties";
}
else {
str3 = "." + File.separator + "javax.comm.properties";
}
localFile = new File(str3);
if (localFile.exists()) {
return new String(str3);
}
return null;
}
}
}
catch (IOException localIOException)
{
}
return null;
}
@elek
Copy link
Author

elek commented Mar 9, 2012

comm.jar name is hardcoded!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment