Source:
<code>public boolean check() { try { <START> File fileCopy = File.createTempFile("modeshape-sequencer-video", ".tmp"); <END> FileOutputStream fileOutputStream = new FileOutputStream(fileCopy); byte[] b = new byte[1024]; while (read(b) != -1) { fileOutputStream.write(b); } fileOutputStream.close(); final Demuxer container = Demuxer.make(); container.open(fileCopy.getAbsolutePath(), null, false, true, null, null); KeyValueBag metadata = container.getMetaData(); for (String key : metadata.getKeys()) { if (key.toLowerCase().equals("title")) { title = metadata.getValue(key); } if (key.toLowerCase().equals("comment")) { comment = metadata.getValue(key); } if (key.toLowerCase().equals("encoder")) { encoder = metadata.getValue(key); } } if (container.getDuration() != Global.NO_PTS) { duration = (float) container.getDuration() / 1000.0 / 1000.0; } if (container.getBitRate() > 0) { bitrate = container.getBitRate(); } for (int i = 0; i < container.getNumStreams(); i++) { StreamMetadata streamMetadata = new StreamMetadata(); DemuxerStream stream = container.getStream(i); Decoder coder = stream.getDecoder(); if (coder.getCodecType() == Type.MEDIA_AUDIO) { streamMetadata.setStreamType("audio"); } else if (coder.getCodecType() == Type.MEDIA_VIDEO) { streamMetadata.setStreamType("video"); } else { streamMetadata.setStreamType("unknown"); } if (coder.getCodec() != null) { streamMetadata.setCodec(coder.getCodec().getName()); } streamMetadata.setSamplerate(nullValueIfInvalid(coder.getSampleRate())); streamMetadata.setChannels(nullValueIfInvalid(coder.getChannels())); streamMetadata.setWidth(nullValueIfInvalid(coder.getWidth())); streamMetadata.setHeight(nullValueIfInvalid(coder.getHeight())); if (coder.getTimeBase() != null) { streamMetadata.setFramerate(nullValueIfInvalid(1.0 / coder.getTimeBase().getDouble())); } streams.add(streamMetadata); } return true; } catch (Exception e) { e.printStackTrace(); } return false; }</code><technical_language>temp file deleted anywhere</technical_language>

Target:
public boolean check() throws Exception { File fileCopy = File.createTempFile("modeshape-sequencer-audio", ".tmp"); IoUtil.write(in, new BufferedOutputStream(new FileOutputStream(fileCopy))); final Demuxer container = Demuxer.make(); container.open(fileCopy.getAbsolutePath(), null, false, true, null, null); boolean deleted = false; try { deleted = fileCopy.delete(); } catch (SecurityException e) { } if (!deleted) { fileCopy.deleteOnExit(); } KeyValueBag metadata = container.getMetaData(); for (String key : metadata.getKeys()) { if (key.toLowerCase().equals("title")) { title = metadata.getValue(key); } if (key.toLowerCase().equals("comment")) { comment = metadata.getValue(key); } if (key.toLowerCase().equals("encoder")) { encoder = metadata.getValue(key); } } if (container.getDuration() != Global.NO_PTS) { duration = (float) container.getDuration() / 1000.0 / 1000.0; } if (container.getBitRate() > 0) { bitrate = container.getBitRate(); } for (int i = 0; i < container.getNumStreams(); i++) { StreamMetadata streamMetadata = new StreamMetadata(); DemuxerStream stream = container.getStream(i); Decoder coder = stream.getDecoder(); if (coder.getCodecType() == Type.MEDIA_AUDIO) { streamMetadata.setStreamType("audio"); } else if (coder.getCodecType() == Type.MEDIA_VIDEO) { streamMetadata.setStreamType("video"); } else { streamMetadata.setStreamType("unknown"); } if (coder.getCodec() != null) { streamMetadata.setCodec(coder.getCodec().getName()); } streamMetadata.setSamplerate(nullValueIfInvalid(coder.getSampleRate())); streamMetadata.setChannels(nullValueIfInvalid(coder.getChannels())); streamMetadata.setWidth(nullValueIfInvalid(coder.getWidth())); streamMetadata.setHeight(nullValueIfInvalid(coder.getHeight())); if (coder.getTimeBase() != null) { streamMetadata.setFramerate(nullValueIfInvalid(1.0 / coder.getTimeBase().getDouble())); } streams.add(streamMetadata); } container.close(); return true; }