#vulnerable code 
                             private void copyResource(InputStream resource, File file) throws IOException {

		OutputStream out = new FileOutputStream(file);

		int length;
		byte[] buf = new byte[1024];

		while ((length = resource.read(buf)) > 0)
			out.write(buf, 0, length);

		out.close();
		resource.close();
	} 
                            #location 13 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                             private void copyResource(InputStream resource, File file) throws IOException {

		OutputStream out = null;
		try {
			out = new FileOutputStream(file);
			int length;
			byte[] buf = new byte[1024];

			while ((length = resource.read(buf)) > 0)
				out.write(buf, 0, length);

		} catch (IOException e) {
			throw e;
		} finally {
			if (out != null)
				out.close();
			resource.close();
		}
	}