diff options
author | Jose <jose@zeroc.com> | 2011-03-14 15:30:59 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2011-03-14 15:30:59 +0100 |
commit | 908723895df8dc6fd1df5175f93e78b669a9bf4c (patch) | |
tree | 93a425db53a7d2104ddcdb64e49ef50f1632bf3d /java/src/Ice/PropertiesI.java | |
parent | 5030 - Patch for slice2cs with scoped constants (diff) | |
download | ice-908723895df8dc6fd1df5175f93e78b669a9bf4c.tar.bz2 ice-908723895df8dc6fd1df5175f93e78b669a9bf4c.tar.xz ice-908723895df8dc6fd1df5175f93e78b669a9bf4c.zip |
5033 - Configuration files and UTF-8 BOM
Diffstat (limited to 'java/src/Ice/PropertiesI.java')
-rw-r--r-- | java/src/Ice/PropertiesI.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/java/src/Ice/PropertiesI.java b/java/src/Ice/PropertiesI.java index 67208025dbc..7d581422f63 100644 --- a/java/src/Ice/PropertiesI.java +++ b/java/src/Ice/PropertiesI.java @@ -369,16 +369,30 @@ public final class PropertiesI implements Properties } else { - java.io.InputStream is = null; + java.io.PushbackInputStream is = null; try { - is = IceInternal.Util.openResource(getClass().getClassLoader(), file); + is = new java.io.PushbackInputStream(IceInternal.Util.openResource(getClass().getClassLoader(), file)); if(is == null) { FileException fe = new FileException(); fe.path = file; throw fe; } + + // + // Skip UTF-8 BOM if present. + // + byte[] bom = new byte[3]; + int read = is.read(bom); + if(read < 3 || bom[0] != (byte)0xEF || bom[1] != (byte)0xBB || bom[2] != (byte)0xBF) + { + if(read > 0) + { + is.unread(bom); + } + } + java.io.InputStreamReader isr = new java.io.InputStreamReader(is, "UTF-8"); java.io.BufferedReader br = new java.io.BufferedReader(isr); parse(br); |