I have the code to get the mime type. It seems to work. When I put mimeType in an if statement, I don't get the desired effect. Here are the snippets.
GET the mime type--
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
String mimeType = mimeTypesMap.getContentType(file);
Now I want to only open a file if the mime type is text--
if (file.isFile()) {
try {
if (mimeType == "text/plain") openFile(file);
} catch (IOException e) {
e.printStackTrace();
System.err.print(" Cannot process file....\n");
}
}
This will not open a text file. Any ideas on why it will not work? openFile(file) works and is not the problem. file is a File Object. Thanks.