List of usage examples for org.eclipse.jdt.internal.compiler.util Messages parser_corruptedFile
String parser_corruptedFile
To view the source code for org.eclipse.jdt.internal.compiler.util Messages parser_corruptedFile.
Click Source Link
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected static long[] readLongTable(String filename) throws java.io.IOException { //files are located at Parser.class directory InputStream stream = Parser.class.getResourceAsStream(filename); if (stream == null) { throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename)); }// w ww . j av a 2s.com byte[] bytes = null; try { stream = new BufferedInputStream(stream); bytes = Util.getInputStreamAsByteArray(stream, -1); } finally { try { stream.close(); } catch (IOException e) { // ignore } } //minimal integrity check (even size expected) int length = bytes.length; if (length % 8 != 0) throw new java.io.IOException(Messages.bind(Messages.parser_corruptedFile, filename)); // convert bytes into longs long[] longs = new long[length / 8]; int i = 0; int longIndex = 0; while (true) { longs[longIndex++] = (((long) (bytes[i++] & 0xFF)) << 56) + (((long) (bytes[i++] & 0xFF)) << 48) + (((long) (bytes[i++] & 0xFF)) << 40) + (((long) (bytes[i++] & 0xFF)) << 32) + (((long) (bytes[i++] & 0xFF)) << 24) + (((long) (bytes[i++] & 0xFF)) << 16) + (((long) (bytes[i++] & 0xFF)) << 8) + (bytes[i++] & 0xFF); if (i == length) break; } return longs; }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected static char[] readTable(String filename) throws java.io.IOException { //files are located at Parser.class directory InputStream stream = Parser.class.getResourceAsStream(filename); if (stream == null) { throw new java.io.IOException(Messages.bind(Messages.parser_missingFile, filename)); }// w ww .j av a2 s .c o m byte[] bytes = null; try { stream = new BufferedInputStream(stream); bytes = Util.getInputStreamAsByteArray(stream, -1); } finally { try { stream.close(); } catch (IOException e) { // ignore } } //minimal integrity check (even size expected) int length = bytes.length; if ((length & 1) != 0) throw new java.io.IOException(Messages.bind(Messages.parser_corruptedFile, filename)); // convert bytes into chars char[] chars = new char[length / 2]; int i = 0; int charIndex = 0; while (true) { chars[charIndex++] = (char) (((bytes[i++] & 0xFF) << 8) + (bytes[i++] & 0xFF)); if (i == length) break; } return chars; }