Java Code Examples for sun.misc.IOUtils#readFully()
The following examples show how to use
sun.misc.IOUtils#readFully() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodUtil.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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; }
Example 2
Source File: CCacheInputStream.java From hottub with GNU General Public License v2.0 | 6 votes |
AuthorizationDataEntry[] readAuth() throws IOException { int num, adtype, adlength; num = readLength4(); if (num > 0) { List<AuthorizationDataEntry> auData = new ArrayList<>(); byte[] data = null; for (int i = 0; i < num; i++) { adtype = read(2); adlength = readLength4(); data = IOUtils.readFully(this, adlength, true); auData.add(new AuthorizationDataEntry(adtype, data)); } return auData.toArray(new AuthorizationDataEntry[auData.size()]); } else return null; }
Example 3
Source File: CCacheInputStream.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
AuthorizationDataEntry[] readAuth() throws IOException { int num, adtype, adlength; num = readLength4(); if (num > 0) { List<AuthorizationDataEntry> auData = new ArrayList<>(); byte[] data = null; for (int i = 0; i < num; i++) { adtype = read(2); adlength = readLength4(); data = IOUtils.readFully(this, adlength, true); auData.add(new AuthorizationDataEntry(adtype, data)); } return auData.toArray(new AuthorizationDataEntry[auData.size()]); } else return null; }
Example 4
Source File: CCacheInputStream.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
AuthorizationDataEntry[] readAuth() throws IOException { int num, adtype, adlength; num = readLength4(); if (num > 0) { List<AuthorizationDataEntry> auData = new ArrayList<>(); byte[] data = null; for (int i = 0; i < num; i++) { adtype = read(2); adlength = readLength4(); data = IOUtils.readFully(this, adlength, true); auData.add(new AuthorizationDataEntry(adtype, data)); } return auData.toArray(new AuthorizationDataEntry[auData.size()]); } else return null; }
Example 5
Source File: CCacheInputStream.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
AuthorizationDataEntry[] readAuth() throws IOException { int num, adtype, adlength; num = readLength4(); if (num > 0) { List<AuthorizationDataEntry> auData = new ArrayList<>(); byte[] data = null; for (int i = 0; i < num; i++) { adtype = read(2); adlength = readLength4(); data = IOUtils.readFully(this, adlength, true); auData.add(new AuthorizationDataEntry(adtype, data)); } return auData.toArray(new AuthorizationDataEntry[auData.size()]); } else return null; }
Example 6
Source File: MethodUtil.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example 7
Source File: AppletClassLoader.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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(); // Fixed #4507227: Slow performance to load // class and resources. [stanleyh] // // Use buffered input stream [stanleyh] InputStream in = new BufferedInputStream(uc.getInputStream()); byte[] b; try { b = IOUtils.readFully(in, len, true); } finally { in.close(); } return b; }
Example 8
Source File: AppletClassLoader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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(); // Fixed #4507227: Slow performance to load // class and resources. [stanleyh] // // Use buffered input stream [stanleyh] InputStream in = new BufferedInputStream(uc.getInputStream()); byte[] b; try { b = IOUtils.readFully(in, len, true); } finally { in.close(); } return b; }
Example 9
Source File: CCacheInputStream.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
byte[] readData() throws IOException { int length; length = readLength4(); if (length == 0) { return null; } else { return IOUtils.readFully(this, length, true); } }
Example 10
Source File: CCacheInputStream.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
EncryptionKey readKey(int version) throws IOException { int keyType, keyLen; keyType = read(2); if (version == KRB5_FCC_FVNO_3) read(2); /* keytype recorded twice in fvno 3 */ keyLen = readLength4(); byte[] bytes = IOUtils.readFully(this, keyLen, true); return new EncryptionKey(bytes, keyType, new Integer(version)); }
Example 11
Source File: CCacheInputStream.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
byte[] readData() throws IOException { int length; length = readLength4(); if (length == 0) { return null; } else { return IOUtils.readFully(this, length, true); } }
Example 12
Source File: CCacheInputStream.java From hottub with GNU General Public License v2.0 | 5 votes |
EncryptionKey readKey(int version) throws IOException { int keyType, keyLen; keyType = read(2); if (version == KRB5_FCC_FVNO_3) read(2); /* keytype recorded twice in fvno 3 */ keyLen = readLength4(); byte[] bytes = IOUtils.readFully(this, keyLen, true); return new EncryptionKey(bytes, keyType, new Integer(version)); }
Example 13
Source File: CCacheInputStream.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
EncryptionKey readKey(int version) throws IOException { int keyType, keyLen; keyType = read(2); if (version == KRB5_FCC_FVNO_3) read(2); /* keytype recorded twice in fvno 3 */ keyLen = readLength4(); byte[] bytes = IOUtils.readFully(this, keyLen, true); return new EncryptionKey(bytes, keyType, new Integer(version)); }
Example 14
Source File: DerValue.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private DerInputStream init(boolean fullyBuffered, InputStream in) throws IOException { tag = (byte)in.read(); byte lenByte = (byte)in.read(); length = DerInputStream.getLength((lenByte & 0xff), in); if (length == -1) { // indefinite length encoding found int readLen = in.available(); int offset = 2; // for tag and length bytes byte[] indefData = new byte[readLen + offset]; indefData[0] = tag; indefData[1] = lenByte; DataInputStream dis = new DataInputStream(in); dis.readFully(indefData, offset, readLen); dis.close(); DerIndefLenConverter derIn = new DerIndefLenConverter(); in = new ByteArrayInputStream(derIn.convert(indefData)); if (tag != in.read()) throw new IOException ("Indefinite length encoding not supported"); length = DerInputStream.getLength(in); } if (fullyBuffered && in.available() != length) throw new IOException("extra data given to DerValue constructor"); byte[] bytes = IOUtils.readFully(in, length, true); buffer = new DerInputBuffer(bytes); return new DerInputStream(buffer); }
Example 15
Source File: DerValue.java From hottub with GNU General Public License v2.0 | 5 votes |
private DerInputStream init(boolean fullyBuffered, InputStream in) throws IOException { tag = (byte)in.read(); byte lenByte = (byte)in.read(); length = DerInputStream.getLength((lenByte & 0xff), in); if (length == -1) { // indefinite length encoding found int readLen = in.available(); int offset = 2; // for tag and length bytes byte[] indefData = new byte[readLen + offset]; indefData[0] = tag; indefData[1] = lenByte; DataInputStream dis = new DataInputStream(in); dis.readFully(indefData, offset, readLen); dis.close(); DerIndefLenConverter derIn = new DerIndefLenConverter(); in = new ByteArrayInputStream(derIn.convert(indefData)); if (tag != in.read()) throw new IOException ("Indefinite length encoding not supported"); length = DerInputStream.getLength(in); } if (fullyBuffered && in.available() != length) throw new IOException("extra data given to DerValue constructor"); byte[] bytes = IOUtils.readFully(in, length, true); buffer = new DerInputBuffer(bytes); return new DerInputStream(buffer); }
Example 16
Source File: DerValue.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private DerInputStream init(boolean fullyBuffered, InputStream in, boolean allowBER) throws IOException { tag = (byte)in.read(); byte lenByte = (byte)in.read(); length = DerInputStream.getLength(lenByte, in); if (length == -1) { // indefinite length encoding found int readLen = in.available(); int offset = 2; // for tag and length bytes byte[] indefData = new byte[readLen + offset]; indefData[0] = tag; indefData[1] = lenByte; DataInputStream dis = new DataInputStream(in); dis.readFully(indefData, offset, readLen); dis.close(); DerIndefLenConverter derIn = new DerIndefLenConverter(); in = new ByteArrayInputStream(derIn.convert(indefData)); if (tag != in.read()) throw new IOException ("Indefinite length encoding not supported"); length = DerInputStream.getLength(in); } if (fullyBuffered && in.available() != length) throw new IOException("extra data given to DerValue constructor"); byte[] bytes = IOUtils.readFully(in, length, true); buffer = new DerInputBuffer(bytes, allowBER); return new DerInputStream(buffer); }
Example 17
Source File: JarFile.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private byte[] getBytes(ZipEntry ze) throws IOException { try (InputStream is = super.getInputStream(ze)) { return IOUtils.readFully(is, (int)ze.getSize(), true); } }
Example 18
Source File: JarFile.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private byte[] getBytes(ZipEntry ze) throws IOException { try (InputStream is = super.getInputStream(ze)) { return IOUtils.readFully(is, (int)ze.getSize(), true); } }
Example 19
Source File: CCacheInputStream.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public PrincipalName readPrincipal(int version) throws IOException, RealmException { int type, length, namelength, kret; String[] pname = null; String realm; /* Read principal type */ if (version == KRB5_FCC_FVNO_1) { type = KRB5_NT_UNKNOWN; } else { type = read(4); } length = readLength4(); List<String> result = new ArrayList<String>(); /* * DCE includes the principal's realm in the count; the new format * does not. */ if (version == KRB5_FCC_FVNO_1) length--; for (int i = 0; i <= length; i++) { namelength = readLength4(); byte[] bytes = IOUtils.readFully(this, namelength, true); result.add(new String(bytes)); } if (result.isEmpty()) { throw new IOException("No realm or principal"); } if (isRealm(result.get(0))) { realm = result.remove(0); if (result.isEmpty()) { throw new IOException("No principal name components"); } return new PrincipalName( type, result.toArray(new String[result.size()]), new Realm(realm)); } try { return new PrincipalName( result.toArray(new String[result.size()]), type); } catch (RealmException re) { return null; } }
Example 20
Source File: TestEvent.java From garmadon with Apache License 2.0 | 4 votes |
TestEvent(InputStream is) throws IOException { bytes = IOUtils.readFully(is, 0, false); }