java.io.BufferedInputStream Java Examples
The following examples show how to use
java.io.BufferedInputStream.
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: FuncSystemProperty.java From TencentKona-8 with GNU General Public License v2.0 | 7 votes |
/** * Retrieve a propery bundle from a specified file * * @param file The string name of the property file. The name * should already be fully qualified as path/filename * @param target The target property bag the file will be placed into. */ public void loadPropertyFile(String file, Properties target) { try { // Use SecuritySupport class to provide priveleged access to property file InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(), file); // get a buffered version BufferedInputStream bis = new BufferedInputStream(is); target.load(bis); // and load up the property bag from this bis.close(); // close out after reading } catch (Exception ex) { // ex.printStackTrace(); throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex); } }
Example #2
Source File: GrammaticalLabelSetFileCacheLoader.java From grammaticus with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @return null if we were unable to load the cached version */ public GrammaticalLabelSetImpl read() { // if we're tracking duplicated labels, we need to load the file directly in order to look at all the labels, so don't load from the cache if (this.language == LanguageProviderFactory.get().getBaseLanguage() && GrammaticalLabelFileParser.isDupeLabelTrackingEnabled()) { return null; } logger.info("Loading " + labelSetName + " from cache"); long start = System.currentTimeMillis(); try (ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(this.cacheFile)))) { GrammaticalLabelSetImpl labelSet = (GrammaticalLabelSetImpl)ois.readObject(); logger.info("Loaded " + this.labelSetName + " from cache in " + (System.currentTimeMillis() - start) + " ms"); return labelSet; } catch (Exception e) { logger.log(Level.INFO, "Could not load " + labelSetName + " from cache: ", e); delete(); } return null; }
Example #3
Source File: Main.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Given a file, find only the properties that are setable by AppletViewer. * * @param inFile A Properties file from which we select the properties of * interest. * @return A Properties object containing all of the AppletViewer * user-specific properties. */ private Properties getAVProps(File inFile) { Properties avProps = new Properties(); // read the file Properties tmpProps = new Properties(); try (FileInputStream in = new FileInputStream(inFile)) { tmpProps.load(new BufferedInputStream(in)); } catch (IOException e) { System.err.println(lookup("main.err.prop.cantread", inFile.toString())); } // pick off the properties we care about for (int i = 0; i < avDefaultUserProps.length; i++) { String value = tmpProps.getProperty(avDefaultUserProps[i][0]); if (value != null) { // the property exists in the file, so replace the default avProps.setProperty(avDefaultUserProps[i][0], value); } else { // just use the default avProps.setProperty(avDefaultUserProps[i][0], avDefaultUserProps[i][1]); } } return avProps; }
Example #4
Source File: FuncSystemProperty.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Retrieve a propery bundle from a specified file * * @param file The string name of the property file. The name * should already be fully qualified as path/filename * @param target The target property bag the file will be placed into. */ public void loadPropertyFile(String file, Properties target) { try { // Use SecuritySupport class to provide priveleged access to property file InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(), file); // get a buffered version BufferedInputStream bis = new BufferedInputStream(is); target.load(bis); // and load up the property bag from this bis.close(); // close out after reading } catch (Exception ex) { // ex.printStackTrace(); throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex); } }
Example #5
Source File: MainScorerImpl.java From ade with GNU General Public License v3.0 | 6 votes |
@Override public final IMainScorer load(File modelFile) throws IOException, AdeException { final ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(modelFile))); try { final MainScorerImpl res = (MainScorerImpl) in.readObject(); final FlowTemplateFactory flow = Ade.getAde().getFlowFactory().getFlowByName(res.m_flowName); final Map<String, FramingFlowType> myFramingFlows = flow.getMyFramingFlows(); res.m_framingFlow = myFramingFlows.get(flow.getUploadFramer()); res.m_scorerSchemas = flow.getScorerSchemas(); res.wakeUp(); return res; } catch (ClassNotFoundException e) { throw new AdeUsageException("Failed loading model from file: " + modelFile.getAbsolutePath(), e); } finally { in.close(); } }
Example #6
Source File: ZooKeeperStateServer.java From localization_nifi with Apache License 2.0 | 6 votes |
public static ZooKeeperStateServer create(final NiFiProperties properties) throws IOException, ConfigException { final File propsFile = properties.getEmbeddedZooKeeperPropertiesFile(); if (propsFile == null) { return null; } if (!propsFile.exists() || !propsFile.canRead()) { throw new IOException("Cannot create Embedded ZooKeeper Server because the Properties File " + propsFile.getAbsolutePath() + " referenced in nifi.properties does not exist or cannot be read"); } final Properties zkProperties = new Properties(); try (final InputStream fis = new FileInputStream(propsFile); final InputStream bis = new BufferedInputStream(fis)) { zkProperties.load(bis); } return new ZooKeeperStateServer(zkProperties); }
Example #7
Source File: JarModifier.java From JReFrameworker with MIT License | 6 votes |
public byte[] extractEntry(String entry) throws IOException { JarInputStream zin = new JarInputStream(new BufferedInputStream(new FileInputStream(jarFile))); JarEntry currentEntry = null; while ((currentEntry = zin.getNextJarEntry()) != null) { if (currentEntry.getName().equals(entry)) { // currentEntry.getSize() may not be accurate, so read bytes into a stream first ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[4096]; while (true) { int n = zin.read(buf); if (n < 0){ break; } baos.write(buf, 0, n); } zin.close(); return baos.toByteArray(); } } zin.close(); return null; }
Example #8
Source File: LinkedBlockingQueueTest.java From database with GNU General Public License v2.0 | 6 votes |
/** * A deserialized serialized queue has same elements in same order */ public void testSerialization() throws Exception { LinkedBlockingQueue q = populatedQueue(SIZE); ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); out.writeObject(q); out.close(); ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); LinkedBlockingQueue r = (LinkedBlockingQueue)in.readObject(); assertEquals(q.size(), r.size()); while (!q.isEmpty()) assertEquals(q.remove(), r.remove()); }
Example #9
Source File: DefaultModuleStateManager.java From sensorhub with Mozilla Public License 2.0 | 6 votes |
@Override public InputStream getAsInputStream(String key) { File dataFile = getDataFile(key); try { if (dataFile.exists()) return new BufferedInputStream(new FileInputStream(dataFile)); } catch (FileNotFoundException e) { } return null; }
Example #10
Source File: FileUtils.java From wind-im with Apache License 2.0 | 6 votes |
public static void writeResourceToFile(String resourceName, File file) throws FileNotFoundException, IOException { if (!file.exists()) { new FileOutputStream(file).close(); } InputStream is = MysqlManager.class.getResourceAsStream(resourceName); BufferedInputStream bis = new BufferedInputStream(is); FileOutputStream fos = new FileOutputStream(file); try { byte[] buffer = new byte[1024]; int bytesLen = 0; while ((bytesLen = bis.read(buffer)) != -1) { fos.write(buffer, 0, bytesLen); } } finally { if (bis != null) { bis.close(); } if (is != null) { is.close(); } if (fos != null) { fos.close(); } } }
Example #11
Source File: RepoDetails.java From fdroidclient with GNU General Public License v3.0 | 6 votes |
@NonNull public static RepoDetails getFromFile(InputStream inputStream, int pushRequests) { try { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); SAXParser parser = factory.newSAXParser(); XMLReader reader = parser.getXMLReader(); RepoDetails repoDetails = new RepoDetails(); MockRepo mockRepo = new MockRepo(100, pushRequests); RepoXMLHandler handler = new RepoXMLHandler(mockRepo, repoDetails); reader.setContentHandler(handler); InputSource is = new InputSource(new BufferedInputStream(inputStream)); reader.parse(is); return repoDetails; } catch (ParserConfigurationException | SAXException | IOException e) { e.printStackTrace(); fail(); // Satisfies the compiler, but fail() will always throw a runtime exception so we never // reach this return statement. return null; } }
Example #12
Source File: DocDownloader.java From netbeans with Apache License 2.0 | 6 votes |
@NonNull public static Future<String> download( @NonNull final URL url, @NonNull final Callable<Boolean> cancel) { return RP.submit(()-> { if (cancel.call()) { return ""; //NOI18N } final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(DocDownloader.class, "LBL_DownloadingDoc")); handle.start(); try { final ByteArrayOutputStream out = new ByteArrayOutputStream(); try(BufferedInputStream in = new BufferedInputStream(url.openStream())) { FileUtil.copy(in, out); } return cancel.call() ? "" //NOI18N : new String(out.toByteArray(),"UTF-8"); //NOI18N } finally { handle.finish(); } }); }
Example #13
Source File: StandardMidiFileReader.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException { FileInputStream fis = new FileInputStream(file); // throws IOException BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize); // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length long length = file.length(); if (length > Integer.MAX_VALUE) { length = MidiFileFormat.UNKNOWN_LENGTH; } MidiFileFormat fileFormat = null; try { fileFormat = getMidiFileFormatFromStream(bis, (int) length, null); } finally { bis.close(); } return fileFormat; }
Example #14
Source File: ArtifactCompilerUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static Pair<InputStream, Long> getArchiveEntryInputStream(VirtualFile sourceFile, final CompileContext context) throws IOException { final String fullPath = sourceFile.getPath(); final int jarEnd = fullPath.indexOf(ArchiveFileSystem.ARCHIVE_SEPARATOR); LOG.assertTrue(jarEnd != -1, fullPath); String pathInJar = fullPath.substring(jarEnd + ArchiveFileSystem.ARCHIVE_SEPARATOR.length()); String jarPath = fullPath.substring(0, jarEnd); final ZipFile jarFile = new ZipFile(new File(FileUtil.toSystemDependentName(jarPath))); final ZipEntry entry = jarFile.getEntry(pathInJar); if (entry == null) { context.addMessage(CompilerMessageCategory.ERROR, "Cannot extract '" + pathInJar + "' from '" + jarFile.getName() + "': entry not found", null, -1, -1); return Pair.empty(); } BufferedInputStream bufferedInputStream = new BufferedInputStream(jarFile.getInputStream(entry)) { @Override public void close() throws IOException { super.close(); jarFile.close(); } }; return Pair.<InputStream, Long>create(bufferedInputStream, entry.getSize()); }
Example #15
Source File: StandardMidiFileReader.java From Bytecoder with Apache License 2.0 | 6 votes |
@Override public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException { FileInputStream fis = new FileInputStream(file); // throws IOException BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize); // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length long length = file.length(); if (length > Integer.MAX_VALUE) { length = MidiFileFormat.UNKNOWN_LENGTH; } MidiFileFormat fileFormat = null; try { fileFormat = getMidiFileFormatFromStream(bis, (int) length, null); } finally { bis.close(); } return fileFormat; }
Example #16
Source File: DefaultExhibitorRestClient.java From xian with Apache License 2.0 | 6 votes |
@Override public String getRaw(String hostname, int port, String uriPath, String mimeType) throws Exception { URI uri = new URI(useSsl ? "https" : "http", null, hostname, port, uriPath, null, null); HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); connection.addRequestProperty("Accept", mimeType); StringBuilder str = new StringBuilder(); InputStream in = new BufferedInputStream(connection.getInputStream()); try { for(;;) { int b = in.read(); if ( b < 0 ) { break; } str.append((char)(b & 0xff)); } } finally { CloseableUtils.closeQuietly(in); } return str.toString(); }
Example #17
Source File: DirectoryManagerImpl.java From Wikidata-Toolkit with Apache License 2.0 | 6 votes |
/** * Returns an input stream that applies the required decompression to the * given input stream. * * @param inputStream * the input stream with the (possibly compressed) data * @param compressionType * the kind of compression * @return an input stream with decompressed data * @throws IOException * if there was a problem creating the decompression streams */ protected InputStream getCompressorInputStream(InputStream inputStream, CompressionType compressionType) throws IOException { switch (compressionType) { case NONE: return inputStream; case GZIP: return new GZIPInputStream(inputStream); case BZ2: return new BZip2CompressorInputStream(new BufferedInputStream( inputStream)); default: throw new IllegalArgumentException("Unsupported compression type: " + compressionType); } }
Example #18
Source File: TemporaryClob.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
/** * Finds the corresponding byte position for the given UTF-8 character * position, starting from the byte position <code>startPos</code>. * See comments in SQLChar.readExternal for more notes on * processing the UTF8 format. * * @param charPos character position * @return Stream position in bytes for the given character position. * @throws EOFException if the character position specified is greater than * the Clob length +1 * @throws IOException if accessing underlying I/O resources fail */ //@GuardedBy(this) private long getBytePosition (final long charPos) throws IOException { long bytePos; if (charPos == this.posCache.getCharPos()) { // We already know the position. bytePos = this.posCache.getBytePos(); } else { long startingBytePosition = 0L; // Default to start at position 0. long charsToSkip = charPos -1; // Subtract one to get number to skip if (charPos > this.posCache.getCharPos()) { // Exploit the last known character position. startingBytePosition = this.posCache.getBytePos(); charsToSkip -= (this.posCache.getCharPos() -1); } InputStream utf8Bytes = this.bytes.getInputStream(startingBytePosition); bytePos = startingBytePosition + UTF8Util.skipFully(new BufferedInputStream(utf8Bytes), charsToSkip); this.posCache.updateCachedPos(charPos, bytePos); } return bytePos; }
Example #19
Source File: ProtoBufFile.java From sofa-jraft with Apache License 2.0 | 6 votes |
/** * Load a protobuf message from file. */ public <T extends Message> T load() throws IOException { File file = new File(this.path); if (!file.exists()) { return null; } final byte[] lenBytes = new byte[4]; try (final FileInputStream fin = new FileInputStream(file); final BufferedInputStream input = new BufferedInputStream(fin)) { readBytes(lenBytes, input); final int len = Bits.getInt(lenBytes, 0); if (len <= 0) { throw new IOException("Invalid message fullName."); } final byte[] nameBytes = new byte[len]; readBytes(nameBytes, input); final String name = new String(nameBytes); readBytes(lenBytes, input); final int msgLen = Bits.getInt(lenBytes, 0); final byte[] msgBytes = new byte[msgLen]; readBytes(msgBytes, input); return ProtobufMsgFactory.newMessageByProtoClassName(name, msgBytes); } }
Example #20
Source File: MCAFile.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public void streamChunk(byte[] data, RunnableVal<NBTStreamer> withStream) throws IOException { if (data != null) { try { FastByteArrayInputStream nbtIn = new FastByteArrayInputStream(data); FastByteArrayInputStream bais = new FastByteArrayInputStream(data); InflaterInputStream iis = new InflaterInputStream(bais, new Inflater(), 1); fieldBuf2.set(iis, byteStore2.get()); BufferedInputStream bis = new BufferedInputStream(iis); NBTInputStream nis = new NBTInputStream(bis); fieldBuf3.set(nis, byteStore3.get()); NBTStreamer streamer = new NBTStreamer(nis); withStream.run(streamer); streamer.readQuick(); } catch (IllegalAccessException unlikely) { unlikely.printStackTrace(); } } }
Example #21
Source File: AudioInfo.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static AudioInfo getAudioInfo(File file) { try { byte header[] = new byte[12]; RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r"); randomAccessFile.readFully(header, 0, 8); randomAccessFile.close(); InputStream input = new BufferedInputStream(new FileInputStream(file)); if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p') { return new M4AInfo(input); } else if (file.getAbsolutePath().endsWith("mp3")) { return new MP3Info(input, file.length()); } else { return null; } } catch (Exception e) { return null; } }
Example #22
Source File: ViewHelper.java From fess with Apache License 2.0 | 5 votes |
protected StreamResponse writeContent(final String configId, final String url, final CrawlerClient client) { final StreamResponse response = new StreamResponse(StringUtil.EMPTY); final ResponseData responseData = client.execute(RequestDataBuilder.newRequestData().get().url(url).build()); if (responseData.getHttpStatusCode() == 404) { response.httpStatus(responseData.getHttpStatusCode()); CloseableUtil.closeQuietly(responseData); return response; } writeFileName(response, responseData); writeContentType(response, responseData); writeNoCache(response, responseData); response.stream(out -> { try (final InputStream is = new BufferedInputStream(responseData.getResponseBody())) { out.write(is); } catch (final IOException e) { if (!(e.getCause() instanceof ClientAbortException)) { throw new FessSystemException("Failed to write a content. configId: " + configId + ", url: " + url, e); } } finally { CloseableUtil.closeQuietly(responseData); } if (logger.isDebugEnabled()) { logger.debug("Finished to write {}", url); } }); return response; }
Example #23
Source File: TreePredictUDFTest.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Test public void testCpu2() throws IOException, ParseException, HiveException { URL url = new URL( "https://gist.githubusercontent.com/myui/ef17aabecf0c0c5bcb69/raw/aac0575b4d43072c6f3c82d9072fdefb61892694/cpu.arff"); InputStream is = new BufferedInputStream(url.openStream()); ArffParser arffParser = new ArffParser(); arffParser.setResponseIndex(6); AttributeDataset data = arffParser.parse(is); double[] datay = data.toArray(new double[data.size()]); double[][] datax = data.toArray(new double[data.size()][]); int n = datax.length; int m = 3 * n / 4; int[] index = Math.permutate(n); double[][] trainx = new double[m][]; double[] trainy = new double[m]; for (int i = 0; i < m; i++) { trainx[i] = datax[index[i]]; trainy[i] = datay[index[i]]; } double[][] testx = new double[n - m][]; double[] testy = new double[n - m]; for (int i = m; i < n; i++) { testx[i - m] = datax[index[i]]; testy[i - m] = datay[index[i]]; } RoaringBitmap attrs = SmileExtUtils.convertAttributeTypes(data.attributes()); RegressionTree tree = new RegressionTree(attrs, new RowMajorDenseMatrix2d(trainx, trainx[0].length), trainy, 20); debugPrint(String.format("RMSE = %.4f\n", rmse(tree, testx, testy))); for (int i = m; i < n; i++) { Assert.assertEquals(tree.predict(testx[i - m]), evalPredict(tree, testx[i - m]), 1.0); } }
Example #24
Source File: FileByFileTool.java From archive-patcher with Apache License 2.0 | 5 votes |
/** * Apply a specified patch to the specified old file, creating the specified new file. * @param oldFile the old file (will be read) * @param patchFile the patch file (will be read) * @param newFile the new file (will be written) * @throws IOException if anything goes wrong */ public static void applyPatch(File oldFile, File patchFile, File newFile) throws IOException { // Figure out temp directory File tempFile = File.createTempFile("fbftool", "tmp"); File tempDir = tempFile.getParentFile(); tempFile.delete(); FileByFileV1DeltaApplier applier = new FileByFileV1DeltaApplier(tempDir); try (FileInputStream patchIn = new FileInputStream(patchFile); BufferedInputStream bufferedPatchIn = new BufferedInputStream(patchIn); FileOutputStream newOut = new FileOutputStream(newFile); BufferedOutputStream bufferedNewOut = new BufferedOutputStream(newOut)) { applier.applyDelta(oldFile, bufferedPatchIn, bufferedNewOut); bufferedNewOut.flush(); } }
Example #25
Source File: Paperclip.java From Paperclip with MIT License | 5 votes |
private static String getMainClass(final Path paperJar) { try ( final InputStream is = new BufferedInputStream(Files.newInputStream(paperJar)); final JarInputStream js = new JarInputStream(is) ) { return js.getManifest().getMainAttributes().getValue("Main-Class"); } catch (final IOException e) { System.err.println("Error reading from patched jar"); e.printStackTrace(); System.exit(1); throw new InternalError(); } }
Example #26
Source File: Utils.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
static byte[] readMagic(BufferedInputStream in) throws IOException { in.mark(4); byte[] magic = new byte[4]; for (int i = 0; i < magic.length; i++) { // read 1 byte at a time, so we always get 4 if (1 != in.read(magic, i, 1)) break; } in.reset(); return magic; }
Example #27
Source File: Vote.java From tsml with GNU General Public License v3.0 | 5 votes |
/** * Load serialized models to include in the ensemble * * @param data training instances (used in a header compatibility check with * each of the loaded models) * * @throws Exception if there is a problem de-serializing a model */ private void loadClassifiers(Instances data) throws Exception { for (String path : m_classifiersToLoad) { if (Environment.containsEnvVariables(path)) { try { path = m_env.substitute(path); } catch (Exception ex) { } } File toLoad = new File(path); if (!toLoad.isFile()) { throw new Exception("\"" + path + "\" does not seem to be a valid file!"); } ObjectInputStream is = new ObjectInputStream(new BufferedInputStream( new FileInputStream(toLoad))); Object c = is.readObject(); if (!(c instanceof Classifier)) { throw new Exception("\"" + path + "\" does not contain a classifier!"); } Object header = null; header = is.readObject(); if (header instanceof Instances) { if (data != null && !data.equalHeaders((Instances) header)) { throw new Exception("\"" + path + "\" was trained with data that is " + "of a differnet structure than the incoming training data"); } } if (header == null) { System.out.println("[Vote] warning: no header instances for \"" + path + "\""); } addPreBuiltClassifier((Classifier) c); } }
Example #28
Source File: TestHDFS.java From BigDataArchitect with Apache License 2.0 | 5 votes |
@Test public void upload() throws Exception { BufferedInputStream input = new BufferedInputStream(new FileInputStream(new File("./data/hello.txt"))); Path outfile = new Path("/msb/out.txt"); FSDataOutputStream output = fs.create(outfile); IOUtils.copyBytes(input,output,conf,true); }
Example #29
Source File: EmptyUTF8ForInnerClassNameTest.java From hottub with GNU General Public License v2.0 | 5 votes |
void checkClassFile(final Path path) throws Exception { ClassFile classFile = ClassFile.read( new BufferedInputStream(Files.newInputStream(path))); for (CPInfo cpInfo : classFile.constant_pool.entries()) { if (cpInfo.getTag() == CONSTANT_Utf8) { CONSTANT_Utf8_info utf8Info = (CONSTANT_Utf8_info)cpInfo; Assert.check(utf8Info.value.length() > 0, "UTF8 with length 0 found at class " + classFile.getName()); } } }
Example #30
Source File: WaveFloatFileReader.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { InputStream stream = url.openStream(); AudioFileFormat format; try { format = getAudioFileFormat(new BufferedInputStream(stream)); } finally { stream.close(); } return format; }