FileImageInputStream imgStream = new FileImageInputStream(file); Iterator<ImageReader> imgReader = ImageIO.getImageReaders(imgStream); imgStream.close(); if (imgReader.hasNext()) { mimeType = "image/" + imgReader.next().getFormatName().toLowerCase();
iis.close(); os.close();
private void readTiePointGrids(Document jDomDocument) throws IOException { final String[] tiePointGridNames = product.getTiePointGridNames(); for (String tiePointGridName : tiePointGridNames) { final TiePointGrid tiePointGrid = product.getTiePointGrid(tiePointGridName); String dataFile = DimapProductHelpers.getTiePointDataFile(jDomDocument, tiePointGrid.getName()); dataFile = FileUtils.exchangeExtension(dataFile, DimapProductConstants.IMAGE_FILE_EXTENSION); FileImageInputStream inputStream = null; try { inputStream = new FileImageInputStream(new File(inputDir, dataFile)); final float[] floats = ((float[]) tiePointGrid.getData().getElems()); inputStream.seek(0); inputStream.readFully(floats, 0, floats.length); inputStream.close(); inputStream = null; // See if we have a -180...+180 or a 0...360 degree discontinuity if (tiePointGrid.getDiscontinuity() != TiePointGrid.DISCONT_NONE) { tiePointGrid.setDiscontinuity(TiePointGrid.getDiscontinuity(floats)); } } catch (IOException e) { throw new IOException( MessageFormat.format("I/O error while reading tie-point grid ''{0}''.", tiePointGridName), e); } finally { if (inputStream != null) { inputStream.close(); } } } }
public SEQReader(File file, boolean variableFramerate) throws IOException { FileImageInputStream in = null; try { in = new FileImageInputStream(file); SEQDecoder decoder = new SEQDecoder(in); track = new SEQMovieTrack(); decoder.produce(track, false); if (variableFramerate) { int removed = removeDuplicateFrames(track); // System.out.println(removed + " frames removed"); } } finally { if (in != null) { in.close(); } } }
@Override protected void tearDown() { try { _inputStream.close(); _outputStream.close(); } catch (IOException e) { } FileUtils.deleteTree(GlobalTestConfig.getBeamTestDataOutputDirectory()); }
@Override protected void tearDown() { try { _inputStream.close(); _outputStream.close(); } catch (IOException e) { } FileUtils.deleteTree(GlobalTestConfig.getBeamTestDataOutputDirectory()); }
@Override protected void tearDown() { try { _inputStream.close(); _outputStream.close(); } catch (IOException e) { } FileUtils.deleteTree(GlobalTestConfig.getBeamTestDataOutputDirectory()); }
@Override protected void tearDown() { try { _inputStream.close(); _outputStream.close(); } catch (IOException e) { } FileUtils.deleteTree(GlobalTestConfig.getBeamTestDataOutputDirectory()); }
@Override protected void tearDown() { try { _inputStream.close(); _outputStream.close(); } catch (IOException e) { } FileUtils.deleteTree(GlobalTestConfig.getBeamTestDataOutputDirectory()); }
@Override protected void tearDown() { try { _inputStream.close(); _outputStream.close(); } catch (IOException e) { } FileUtils.deleteTree(GlobalTestConfig.getBeamTestDataOutputDirectory()); }
@Override protected void tearDown() { try { _inputStream.close(); _outputStream.close(); } catch (IOException e) { } FileUtils.deleteTree(GlobalTestConfig.getBeamTestDataOutputDirectory()); }
private byte[] getCurrentByteArray(Band band) { FileImageInputStream inputStream = createInputStream(band); int fileLength = new Long(inputStream.length()).intValue(); byte[] currentBytes = new byte[fileLength]; try { inputStream.readFully(currentBytes); inputStream.close(); } catch (FileNotFoundException e) { fail("FileNotFoundException not expected"); } catch (IOException e) { fail("IOException not expected"); } return currentBytes; }
if (fis != null) { try { fis.close(); } catch (Throwable t) {
private float[] getCurrentByteArray(TiePointGrid grid) { FileImageInputStream inputStream = createInputStream(grid); int fileLength = new Long(inputStream.length()).intValue(); int arrayLength = fileLength / ProductData.getElemSize(ProductData.TYPE_FLOAT32); float[] currentFloats = new float[arrayLength]; try { inputStream.readFully(currentFloats, 0, arrayLength); inputStream.close(); } catch (FileNotFoundException e) { fail("FileNotFoundException not expected"); } catch (IOException e) { fail("IOException not expected"); } return currentFloats; }
public void testFileImageIOStreams() { final float[] outputLineBuffer = new float[_lineLength]; for (int i = 0; i < outputLineBuffer.length; i++) { outputLineBuffer[i] = i + 12; } final float[] inputLineBuffer = new float[_lineLength]; try { final FileImageInputStream inputStream = new FileImageInputStream(_testFile); final FileImageOutputStream outputStream = new FileImageOutputStream(_testFile); final int byteLineSize = _lineLength * elemsize; for (int offset = 0; offset < byteLineSize * _numLines; offset += byteLineSize) { inputStream.seek(offset); inputStream.readFully(inputLineBuffer, 0, _lineLength); outputStream.seek(offset); outputStream.writeFloats(outputLineBuffer, 0, _lineLength); } inputStream.close(); outputStream.close(); final FileImageInputStream verifyInputStream = new FileImageInputStream(_testFile); for (int offset = 0; offset < byteLineSize * _numLines; offset += byteLineSize) { verifyInputStream.seek(offset); verifyInputStream.readFully(inputLineBuffer, 0, _lineLength); assertEquals(true, Arrays.equals(inputLineBuffer, outputLineBuffer)); } verifyInputStream.close(); } catch (IOException e) { fail("IOException not expected"); } }
if (stream_in != null) { stream_in.flush(); stream_in.close();
if (stream_in != null) { stream_in.flush(); stream_in.close();
if (stream_in != null) { stream_in.flush(); stream_in.close();
if (stream_in != null) { stream_in.flush(); stream_in.close();