You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
loadModel will currently show a warning in eclipse and other java IDE that the reader of type BufferedReader has not been closed. This is due to a try/catch/finally/needed. I have been watching these to transfer from c++ opengl work to java and noticed this issue and just wanted to give a heads up. I edited my personal copy of the code here...
public static Model loadModel(File f) throws IOException {
BufferedReader reader = null;
Model m = null;
try{
reader = new BufferedReader(new FileReader(f));
m = new Model();
String line;
while ((line = reader.readLine()) != null) {
String prefix = line.split(" ")[0];
if (prefix.equals("#")) {
continue;
} else if (prefix.equals("v")) {
m.getVertices().add(parseVertex(line));
} else if (prefix.equals("vn")) {
m.getNormals().add(parseNormal(line));
} else if (prefix.equals("f")) {
m.getFaces().add(parseFace(m.hasNormals(), line));
} else {
throw new RuntimeException("OBJ file contains line which cannot be parsed correctly: " + line);
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}finally{
reader.close();
}
return m;
}
The text was updated successfully, but these errors were encountered:
loadModel will currently show a warning in eclipse and other java IDE that the reader of type BufferedReader has not been closed. This is due to a try/catch/finally/needed. I have been watching these to transfer from c++ opengl work to java and noticed this issue and just wanted to give a heads up. I edited my personal copy of the code here...
The text was updated successfully, but these errors were encountered: