Some sun.misc internal APIs are deprectaed in JDK 9 and will be encapsulated or removed in a future release.
@Override public RecordSchema getSchema(Map<String, String> variables, InputStream contentStream, RecordSchema readSchema) throws SchemaNotFoundException, IOException { byte[] bytes = IOUtils.readFully(contentStream, -1, true); ObjectMapper mapper = new ObjectMapper(); return convertSchema(mapper.readValue(bytes, Map.class)); }
/** * Public constructor * @param name the name * @param audioStream the {@link AudioInputStream} * @throws IOException if cannot transform the audio stream into byte array */ public Diction(String name, AudioInputStream audioStream) throws IOException { this.name = name; this.audioStream = IOUtils.readFully(audioStream, -1, true); }
import sun.misc.IOUtils; ... InputStream in = ...; byte[] buf = IOUtils.readFully(in, -1, false);
@Override public RecordSchema getSchema(Map<String, String> variables, InputStream contentStream, RecordSchema readSchema) throws SchemaNotFoundException, IOException { byte[] bytes = IOUtils.readFully(contentStream, -1, true); ObjectMapper mapper = new ObjectMapper(); return convertSchema(mapper.readValue(bytes, Map.class)); }
private static byte[] getBytes(URL url) throws IOException { URLConnection uc = url.openConnection(); if (uc instanceof java.net.HttpURLConnection) { java.net.HttpURLConnection huc = (java.net.HttpURLConnection) uc; int code = huc.getResponseCode(); if (code >= java.net.HttpURLConnection.HTTP_BAD_REQUEST) { throw new IOException("open HTTP connection failed."); } } int len = uc.getContentLength(); InputStream in = new BufferedInputStream(uc.getInputStream()); byte[] b; try { b = IOUtils.readFully(in, len, true); } finally { in.close(); } return b; }
InputStream resourceAsStream = ColorStylesGenerator.class.getClassLoader().getResourceAsStream("color-template.css"); InputStream whiteColorResourceAsStream = ColorStylesGenerator.class.getClassLoader().getResourceAsStream("all-colors-section.css"); byte[] bytes = IOUtils.readFully(resourceAsStream, Integer.MAX_VALUE, false); byte[] whiteBytes = IOUtils.readFully(whiteColorResourceAsStream, Integer.MAX_VALUE, false);
InputStream resourceAsStream = ColorStylesGenerator.class.getClassLoader().getResourceAsStream("color-template.css"); InputStream whiteColorResourceAsStream = ColorStylesGenerator.class.getClassLoader().getResourceAsStream("all-colors-section.css"); byte[] bytes = IOUtils.readFully(resourceAsStream, Integer.MAX_VALUE, false); byte[] whiteBytes = IOUtils.readFully(whiteColorResourceAsStream, Integer.MAX_VALUE, false);