You're not using a good method to retrieve the string representation of your source code. You can use an alternative method for read a file from your path and return a string representation of source:
public static String readFileToString(String filePath) throws IOException {
StringBuilder fileData = new StringBuilder(1000);
BufferedReader reader = new BufferedReader(new FileReader(filePath));
char[] buf = new char[10];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
// System.out.println(numRead);
String readData = String.valueOf(buf, 0, numRead);
fileData.append(readData);
buf = new char[1024];
}
reader.close();
return fileData.toString();
}
Remember to always check whether it is an actual file before calling readFileToString(filePath) eg:
String filePath = file.getAbsolutePath();
if (file.isFile ()))
String source = readFileToString(filePath)
Alternatively you can print the contents of rawContent returned from your method readFile and check that the code you want to parse is actually the same as what you mean.