private byte[] read() { try (InputStream inputStream = this.resourceReferenceHandler.openInputStream(getResource())) { final byte[] array = new byte[1024]; byte[] buffer = new byte[0]; int length = 0; while ((length = inputStream.read(array)) > -1) { buffer = concat(buffer, array, length); } return buffer; } catch (final IOException exception) { final ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); final PrintStream outputStream = new PrintStream(arrayOutputStream); exception.printStackTrace(outputStream); return arrayOutputStream.toByteArray(); } }
private byte[] read() { try (InputStream inputStream = this.resourceReferenceHandler.openInputStream(getResource())) { final byte[] array = new byte[1024]; byte[] buffer = new byte[0]; int length = 0; while ((length = inputStream.read(array)) > -1) { buffer = concat(buffer, array, length); } return buffer; } catch (final IOException exception) { final ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); final PrintStream outputStream = new PrintStream(arrayOutputStream); exception.printStackTrace(outputStream); return arrayOutputStream.toByteArray(); } }
private byte[] read(final IResourceReference resourceReference) { if (resourceReference == null) { final String message = "Error loading text resource, resource value is not defined"; //$NON-NLS-1$ logger.log(ILevel.ERROR, message); throw new RuntimeException(message); } try (InputStream input = this.resourceReferenceHandler.openInputStream(resourceReference);) { return read(input); } catch (final Exception e) { final String message = MessageFormat .format("Error loading text resource ''{0}''", ResourceReferenceUtilities.toString(resourceReference)); //$NON-NLS-1$ logger.log(ILevel.ERROR, message, e); throw new RuntimeException(message, e); } }
private byte[] read(final IResourceReference resourceReference) { if (resourceReference == null) { final String message = "Error loading text resource, resource value is not defined"; //$NON-NLS-1$ logger.log(ILevel.ERROR, message); throw new RuntimeException(message); } try (InputStream input = this.resourceReferenceHandler.openInputStream(resourceReference);) { return read(input); } catch (final Exception e) { final String message = MessageFormat .format("Error loading text resource ''{0}''", ResourceReferenceUtilities.toString(resourceReference)); //$NON-NLS-1$ logger.log(ILevel.ERROR, message, e); throw new RuntimeException(message, e); } }