import org.tizen.common.file.FileHandler;\r
import org.tizen.common.file.FileHandler.Attribute;\r
import org.tizen.common.file.IResource;\r
+import org.tizen.common.util.IOUtil;\r
\r
public class\r
Resource implements IResource\r
\r
public void setContents( byte[] contents ) throws IOException\r
{\r
- setContents( new ByteArrayInputStream( contents ) );\r
+ ByteArrayInputStream bais = null;\r
+ try {\r
+ bais = new ByteArrayInputStream( contents );\r
+ setContents( bais );\r
+ } finally {\r
+ IOUtil.tryClose(bais);\r
+ }\r
}\r
\r
@Override\r
package org.tizen.common.core.command.file;
import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import org.tizen.common.core.command.ExecutionContext;
import org.tizen.common.core.command.Executor;
+import org.tizen.common.util.IOUtil;
import org.tizen.common.util.ObjectUtil;
public class
logger.trace( "Trying write {} in {} bytes", path, safeBytes.length );
- context.getFileHandler().write(
- path,
- new ByteArrayInputStream( safeBytes )
- );
+ InputStream is = null;
+ try {
+ is = new ByteArrayInputStream( safeBytes );
+ context.getFileHandler().write(
+ path,
+ is
+ );
+ } finally {
+ IOUtil.tryClose(is);
+ }
}
}
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.Collection;
tryClose( zipOut );
}
+ InputStream is = new ByteArrayInputStream( byteOut.toByteArray() );
try {
- handler.write( path, new ByteArrayInputStream( byteOut.toByteArray() ) );
+ handler.write( path, is );
context.getPrompter().notify( MessageFormat.format( "Widget( {0} ) is created successfully.", path ) );
}
catch ( IOException e )
{
throw new IllegalStateException( e );
// TODO Handle
+ } finally {
+ tryClose(is);
}
}