}
// Old local files and remote files, load 'em up. UnicodeReader will
// check for BOMs and handle them correctly in all cases, then pass
// rest of stream down to InputStreamReader.
UnicodeReader ur = new UnicodeReader(loc.getInputStream(), defaultEnc);
// Remove listener so dirty flag doesn't get set when loading a file.
Document doc = getDocument();
doc.removeDocumentListener(this);
BufferedReader r = new BufferedReader(ur);
try {
read(r, null);
} finally {
doc.addDocumentListener(this);
r.close();
}
// No IOException thrown, so we can finally change the location.
charSet = ur.getEncoding();
String old = getFileFullPath();
this.loc = loc;
setDirty(false);
setCaretPosition(0);
firePropertyChange(FULL_PATH_PROPERTY, old, getFileFullPath());