List of usage examples for java.io File setExecutable
public boolean setExecutable(boolean executable)
From source file:org.flowerplatform.web.git.GitUtils.java
/** * Executes the corresponding Windows/Linux script to create a virtual repository. *///w ww.j a v a2s . c om @SuppressWarnings("restriction") public String run_git_workdir_cmd(String source, String destination) { File file = null; try { String OS = System.getProperty("os.name").toLowerCase(); boolean isWindows = true; if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0) { isWindows = false; } else if (!(OS.indexOf("win") >= 0)) { return "git-new-workdir command only supports format for Windows/Linux!"; } String cmdName = isWindows ? GIT_NEW_WORKDIR_WIN : GIT_NEW_WORKDIR_LINUX; file = File.createTempFile("git", isWindows ? ".cmd" : ".sh", new File(FrameworkProperties.getProperty("flower.server.tmpdir"))); InputStream is = getClass().getClassLoader().getResourceAsStream("META-INF/git/" + cmdName); OutputStream out = new FileOutputStream(file); IOUtils.copy(is, out); is.close(); out.close(); if (!file.exists()) { return String.format("%s wasn't found at '%s'!", cmdName, file.getAbsolutePath()); } file.setExecutable(true); List<String> cmd = new ArrayList<String>(); cmd.add(file.getAbsolutePath()); cmd.add(source); cmd.add(destination); if (isWindows) { String git = CommonPlugin.getInstance().getFlowerProperties().getProperty(GIT_INSTALL_DIR) + "/cmd/git.exe"; if (!new File(git).exists()) { return String.format("Git executable wasn't found at '%s'! Please verify '%s' property!", git, GIT_INSTALL_DIR); } cmd.add(git); } Process proc = Runtime.getRuntime().exec(cmd.toArray(new String[cmd.size()])); if (logger.isDebugEnabled()) { // any error message? StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR"); errorGobbler.start(); // any output? StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT"); outputGobbler.start(); } // any error??? int exitVal = proc.waitFor(); switch (exitVal) { case 0: return null; // OK case 1: return String.format("Usage: %s ^<repository^> ^<new_workdir^> %s[^<branch^>]", cmdName, isWindows ? "^<git_exe_location^> " : ""); case 2: return String.format("Directory not found: '%s'!", source); case 3: return String.format("Not a git repository: '%s'!", source); case 4: return String.format("'%s' is a bare repository!", source); case 5: return String.format("Destination directory '%s' already exists!", destination); case 6: return String.format("Unable to create '%s'!", destination); } } catch (Exception e) { logger.error("Exception thrown while running git-new-workdir command!", e); return "Exception thrown while creating working directory!"; } finally { if (file != null) { file.delete(); } } return null; }
From source file:com.jayway.maven.plugins.android.AbstractEmulatorMojo.java
/** * Writes the script to start the emulator in the background for windows based environments. * * @return absolute path name of start script * @throws IOException//from ww w .ja va 2 s. c o m * @throws MojoExecutionException */ private String writeEmulatorStartScriptWindows() throws MojoExecutionException { String filename = SCRIPT_FOLDER + "\\android-maven-plugin-emulator-start.vbs"; File file = new File(filename); PrintWriter writer = null; try { writer = new PrintWriter(new FileWriter(file)); // command needs to be assembled before unique window title since it parses settings and sets up parsedAvd // and others. String command = assembleStartCommandLine(); String uniqueWindowTitle = "AndroidMavenPlugin-AVD" + parsedAvd; writer.println("Dim oShell"); writer.println("Set oShell = WScript.CreateObject(\"WScript.shell\")"); String cmdPath = System.getenv("COMSPEC"); if (cmdPath == null) { cmdPath = "cmd.exe"; } String cmd = cmdPath + " /X /C START /SEPARATE \"\"" + uniqueWindowTitle + "\"\" " + command.trim(); writer.println("oShell.run \"" + cmd + "\""); } catch (IOException e) { getLog().error("Failure writing file " + filename); } finally { if (writer != null) { writer.flush(); writer.close(); } } file.setExecutable(true); return filename; }
From source file:net.rim.ejde.internal.packaging.PackagingManager.java
private String getRAPCPath() { String rapcPath = IConstants.EMPTY_STRING; try {//w ww . j av a 2s . c o m IVMInstall vm = null; if (_bbProject.getProject().hasNature(BlackBerryProjectCoreNature.NATURE_ID)) { vm = JavaRuntime.getVMInstall(_bbProject); } else { // for java proejct, we use the default BB jre vm = VMUtils.getDefaultBBVM(); } if (vm != null) { File vmLocation = vm.getInstallLocation(); IPath vmPath = new Path(vmLocation.getPath()); vmPath = vmPath.append("bin"); if (OSUtils.isWindows()) { vmPath = vmPath.append("rapc.exe"); } else { // Make sure preverify is in executable state File f = null; if ((f = new File(vmPath + File.separator + IConstants.PREVERIFY_FILE_NAME)).exists()) { if (!f.canExecute()) { f.setExecutable(true); } } // invoke rapc.jar instead of rapc.exe vmPath = vmPath.append("rapc.jar"); } rapcPath = vmPath.toOSString(); } else { throw ProblemFactory.create_VM_MISSING_exception(_bbProject.getElementName()); } } catch (CoreException e) { _log.error("getRapcPath: " + e.getMessage()); } return rapcPath; }
From source file:de.huberlin.cuneiform.compiler.local.LocalDispatcher.java
protected Set<JsonReportEntry> dispatch(Invocation invocation) throws IOException, InterruptedException, NotDerivableException, JSONException { File scriptFile; Process process;//from w w w .j a v a2s .c o m int exitValue; Set<JsonReportEntry> report; String line; String[] arg; String value; int i; StringBuffer buf; File location; File reportFile; StreamConsumer stdoutConsumer, errConsumer; ExecutorService executor; String signature; Path srcPath, destPath; File successMarker; if (invocation == null) throw new NullPointerException("Invocation must not be null."); if (!invocation.isReady()) throw new RuntimeException("Cannot dispatch invocation that is not ready."); location = new File(buildDir.getAbsolutePath() + "/" + invocation.getSignature()); successMarker = new File(location.getAbsolutePath() + "/" + SUCCESS_FILENAME); reportFile = new File(location.getAbsolutePath() + "/" + Invocation.REPORT_FILENAME); if (!successMarker.exists()) { if (location.exists()) FileUtils.deleteDirectory(location); if (!location.mkdirs()) throw new IOException("Could not create invocation location."); scriptFile = new File(location.getAbsolutePath() + "/" + SCRIPT_FILENAME); try (BufferedWriter writer = new BufferedWriter(new FileWriter(scriptFile, false))) { // write away script writer.write(invocation.toScript()); } scriptFile.setExecutable(true); for (String filename : invocation.getStageInList()) { if (filename.charAt(0) != '/' && filename.indexOf('_') >= 0) { signature = filename.substring(0, filename.indexOf('_')); srcPath = FileSystems.getDefault() .getPath(buildDir.getAbsolutePath() + "/" + signature + "/" + filename); destPath = FileSystems.getDefault() .getPath(buildDir.getAbsolutePath() + "/" + invocation.getSignature() + "/" + filename); Files.createSymbolicLink(destPath, srcPath); } } arg = new String[] { "/usr/bin/time", "-a", "-o", location.getAbsolutePath() + "/" + Invocation.REPORT_FILENAME, "-f", "{" + JsonReportEntry.ATT_TIMESTAMP + ":" + System.currentTimeMillis() + "," + JsonReportEntry.ATT_RUNID + ":\"" + invocation.getDagId() + "\"," + JsonReportEntry.ATT_TASKID + ":" + invocation.getTaskNodeId() + "," + JsonReportEntry.ATT_TASKNAME + ":\"" + invocation.getTaskName() + "\"," + JsonReportEntry.ATT_LANG + ":\"" + invocation.getLangLabel() + "\"," + JsonReportEntry.ATT_INVOCID + ":" + invocation.getSignature() + "," + JsonReportEntry.ATT_KEY + ":\"" + JsonReportEntry.KEY_INVOC_TIME + "\"," + JsonReportEntry.ATT_VALUE + ":" + "{\"realTime\":%e,\"userTime\":%U,\"sysTime\":%S," + "\"maxResidentSetSize\":%M,\"avgResidentSetSize\":%t," + "\"avgDataSize\":%D,\"avgStackSize\":%p,\"avgTextSize\":%X," + "\"nMajPageFault\":%F,\"nMinPageFault\":%R," + "\"nSwapOutMainMem\":%W,\"nForcedContextSwitch\":%c," + "\"nWaitContextSwitch\":%w,\"nIoRead\":%I,\"nIoWrite\":%O," + "\"nSocketRead\":%r,\"nSocketWrite\":%s,\"nSignal\":%k}}", scriptFile.getAbsolutePath() }; // run script process = Runtime.getRuntime().exec(arg, null, location); executor = Executors.newCachedThreadPool(); stdoutConsumer = new StreamConsumer(process.getInputStream()); executor.execute(stdoutConsumer); errConsumer = new StreamConsumer(process.getErrorStream()); executor.execute(errConsumer); executor.shutdown(); exitValue = process.waitFor(); if (!executor.awaitTermination(4, TimeUnit.SECONDS)) throw new RuntimeException("Consumer threads did not finish orderly."); try (BufferedWriter reportWriter = new BufferedWriter(new FileWriter(reportFile, true))) { if (exitValue != 0) { System.err.println("[script]"); try (BufferedReader reader = new BufferedReader(new StringReader(invocation.toScript()))) { i = 0; while ((line = reader.readLine()) != null) System.err.println(String.format("%02d %s", ++i, line)); } System.err.println("[out]"); try (BufferedReader reader = new BufferedReader( new StringReader(stdoutConsumer.getContent()))) { while ((line = reader.readLine()) != null) System.err.println(line); } System.err.println("[err]"); try (BufferedReader reader = new BufferedReader(new StringReader(errConsumer.getContent()))) { while ((line = reader.readLine()) != null) System.err.println(line); } System.err.println("[end]"); throw new RuntimeException("Invocation of task '" + invocation.getTaskName() + "' with signature " + invocation.getSignature() + " terminated with non-zero exit value. Exit value was " + exitValue + "."); } try (BufferedReader reader = new BufferedReader(new StringReader(stdoutConsumer.getContent()))) { buf = new StringBuffer(); while ((line = reader.readLine()) != null) buf.append(line.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\"")).append('\n'); value = buf.toString(); if (!value.isEmpty()) reportWriter.write(new JsonReportEntry(invocation, JsonReportEntry.KEY_INVOC_STDOUT, value) .toString()); } try (BufferedReader reader = new BufferedReader(new StringReader(errConsumer.getContent()))) { buf = new StringBuffer(); while ((line = reader.readLine()) != null) buf.append(line.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\"")).append('\n'); value = buf.toString(); if (!value.isEmpty()) reportWriter.write(new JsonReportEntry(invocation, JsonReportEntry.KEY_INVOC_STDERR, value) .toString()); } } } // gather report report = new HashSet<>(); try (BufferedReader reader = new BufferedReader(new FileReader(reportFile))) { while ((line = reader.readLine()) != null) { line = line.trim(); if (line.isEmpty()) continue; report.add(new JsonReportEntry(line)); } } invocation.evalReport(report); if (!successMarker.exists()) if (!successMarker.createNewFile()) throw new IOException("Could not create success marker."); return report; }
From source file:it.drwolf.ridire.index.cwb.CWBConcordancer.java
private void executeQueryForContext(CWBResult item, File contextFile, boolean left) throws ExecuteException, IOException { Executor executor = new DefaultExecutor(); File tempSh = File.createTempFile("ridireCTX", ".sh"); StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("LC_ALL=C && "); if (left) {//from ww w . j a va 2 s. co m stringBuffer.append(this.cwbdecodeExecutable + " -r " + this.cqpRegistry + " -C -s " + Math.max(0, item.getStartPosition() - 101) + " -e " + (item.getStartPosition() - 1) + " " + this.cqpCorpusName + " -P word" + " > " + contextFile.getAbsolutePath() + "\n"); } else { stringBuffer.append(this.cwbdecodeExecutable + " -r " + this.cqpRegistry + " -C -s " + (item.getEndPosition() + 1) + " -e " + (item.getEndPosition() + 101) + " " + this.cqpCorpusName + " -P word" + " > " + contextFile.getAbsolutePath() + "\n"); } FileUtils.writeStringToFile(tempSh, stringBuffer.toString()); tempSh.setExecutable(true); CommandLine commandLine = new CommandLine(tempSh.getAbsolutePath()); executor.execute(commandLine); FileUtils.deleteQuietly(tempSh); }
From source file:com.amazonaws.services.kinesis.producer.KinesisProducer.java
private void extractBinaries() { synchronized (EXTRACT_BIN_MUTEX) { final List<File> watchFiles = new ArrayList<>(2); String os = SystemUtils.OS_NAME; if (SystemUtils.IS_OS_WINDOWS) { os = "windows"; } else if (SystemUtils.IS_OS_LINUX) { os = "linux"; } else if (SystemUtils.IS_OS_MAC_OSX) { os = "osx"; } else {/*w ww . ja va 2s . com*/ throw new RuntimeException("Your operation system is not supported (" + os + "), the KPL only supports Linux, OSX and Windows"); } String root = "amazon-kinesis-producer-native-binaries"; String tmpDir = config.getTempDirectory(); if (tmpDir.trim().length() == 0) { tmpDir = System.getProperty("java.io.tmpdir"); } tmpDir = Paths.get(tmpDir, root).toString(); pathToTmpDir = tmpDir; String binPath = config.getNativeExecutable(); if (binPath != null && !binPath.trim().isEmpty()) { pathToExecutable = binPath.trim(); log.warn("Using non-default native binary at " + pathToExecutable); pathToLibDir = ""; } else { log.info("Extracting binaries to " + tmpDir); try { File tmpDirFile = new File(tmpDir); if (!tmpDirFile.exists() && !tmpDirFile.mkdirs()) { throw new IOException("Could not create tmp dir " + tmpDir); } String extension = os.equals("windows") ? ".exe" : ""; String executableName = "kinesis_producer" + extension; byte[] bin = IOUtils.toByteArray(this.getClass().getClassLoader() .getResourceAsStream(root + "/" + os + "/" + executableName)); MessageDigest md = MessageDigest.getInstance("SHA1"); String mdHex = DatatypeConverter.printHexBinary(md.digest(bin)).toLowerCase(); pathToExecutable = Paths.get(pathToTmpDir, "kinesis_producer_" + mdHex + extension).toString(); File extracted = new File(pathToExecutable); watchFiles.add(extracted); if (extracted.exists()) { try (FileInputStream fis = new FileInputStream(extracted); FileLock lock = fis.getChannel().lock(0, Long.MAX_VALUE, true)) { boolean contentEqual = false; if (extracted.length() == bin.length) { byte[] existingBin = IOUtils.toByteArray(new FileInputStream(extracted)); contentEqual = Arrays.equals(bin, existingBin); } if (!contentEqual) { throw new SecurityException("The contents of the binary " + extracted.getAbsolutePath() + " is not what it's expected to be."); } } } else { try (FileOutputStream fos = new FileOutputStream(extracted); FileLock lock = fos.getChannel().lock()) { IOUtils.write(bin, fos); } extracted.setExecutable(true); } String certFileName = "b204d74a.0"; File certFile = new File(pathToTmpDir, certFileName); if (!certFile.exists()) { try (FileOutputStream fos = new FileOutputStream(certFile); FileLock lock = fos.getChannel().lock()) { byte[] certs = IOUtils.toByteArray(this.getClass().getClassLoader() .getResourceAsStream("cacerts/" + certFileName)); IOUtils.write(certs, fos); } } watchFiles.add(certFile); pathToLibDir = pathToTmpDir; FileAgeManager.instance().registerFiles(watchFiles); } catch (Exception e) { throw new RuntimeException("Could not copy native binaries to temp directory " + tmpDir, e); } } } }
From source file:lc.kra.servlet.FileManagerServlet.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) *//*from www. j a v a 2 s . com*/ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Files files = null; File file = null, parent; String path = request.getParameter("path"), type = request.getContentType(), search = request.getParameter("search"), mode; if (path == null || !(file = new File(path)).exists()) files = new Roots(); else if (request.getParameter("zip") != null) { File zipFile = File.createTempFile(file.getName() + "-", ".zip"); if (file.isFile()) ZipUtil.addEntry(zipFile, file.getName(), file); else if (file.isDirectory()) ZipUtil.pack(file, zipFile); downloadFile(response, zipFile, permamentName(zipFile.getName()), "application/zip"); } else if (request.getParameter("delete") != null) { if (file.isFile()) file.delete(); else if (file.isDirectory()) { java.nio.file.Files.walkFileTree(file.toPath(), new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { java.nio.file.Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { java.nio.file.Files.delete(dir); return FileVisitResult.CONTINUE; } }); } } else if ((mode = request.getParameter("mode")) != null) { boolean add = mode.startsWith("+"); if (mode.indexOf('r') > -1) file.setReadable(add); if (mode.indexOf('w') > -1) file.setWritable(add); if (mode.indexOf('x') > -1) file.setExecutable(add); } else if (file.isFile()) downloadFile(response, file); else if (file.isDirectory()) { if (search != null && !search.isEmpty()) files = new Search(file.toPath(), search); else if (type != null && type.startsWith("multipart/form-data")) { for (Part part : request.getParts()) { String name; if ((name = partFileName(part)) == null) //retrieves <input type="file" name="...">, no other (e.g. input) form fields continue; if (request.getParameter("unzip") == null) try (OutputStream output = new FileOutputStream(new File(file, name))) { copyStream(part.getInputStream(), output); } else ZipUtil.unpack(part.getInputStream(), file); } } else files = new Directory(file); } else throw new ServletException("Unknown type of file or folder."); if (files != null) { final PrintWriter writer = response.getWriter(); writer.println( "<!DOCTYPE html><html><head><style>*,input[type=\"file\"]::-webkit-file-upload-button{font-family:monospace}</style></head><body>"); writer.println("<p>Current directory: " + files + "</p><pre>"); if (!(files instanceof Roots)) { writer.print( "<form method=\"post\"><label for=\"search\">Search Files:</label> <input type=\"text\" name=\"search\" id=\"search\" value=\"" + (search != null ? search : "") + "\"> <button type=\"submit\">Search</button></form>"); writer.print( "<form method=\"post\" enctype=\"multipart/form-data\"><label for=\"upload\">Upload Files:</label> <button type=\"submit\">Upload</button> <button type=\"submit\" name=\"unzip\">Upload & Unzip</button> <input type=\"file\" name=\"upload[]\" id=\"upload\" multiple></form>"); writer.println(); } if (files instanceof Directory) { writer.println("+ <a href=\"?path=" + URLEncoder.encode(path, ENCODING) + "\">.</a>"); if ((parent = file.getParentFile()) != null) writer.println("+ <a href=\"?path=" + URLEncoder.encode(parent.getAbsolutePath(), ENCODING) + "\">..</a>"); else writer.println("+ <a href=\"?path=\">..</a>"); } for (File child : files.listFiles()) { writer.print(child.isDirectory() ? "+ " : " "); writer.print("<a href=\"?path=" + URLEncoder.encode(child.getAbsolutePath(), ENCODING) + "\" title=\"" + child.getAbsolutePath() + "\">" + child.getName() + "</a>"); if (child.isDirectory()) writer.print(" <a href=\"?path=" + URLEncoder.encode(child.getAbsolutePath(), ENCODING) + "&zip\" title=\"download\">⇩</a>"); if (search != null && !search.isEmpty()) writer.print(" <a href=\"?path=" + URLEncoder.encode(child.getParentFile().getAbsolutePath(), ENCODING) + "\" title=\"go to parent folder\">🗁</a>"); writer.println(); } writer.print("</pre></body></html>"); writer.flush(); } }
From source file:com.github.jarlakxen.embedphantomjs.PhantomJSReference.java
private void downloadPhantomJS(File binaryFile) throws IOException { Properties properties = new Properties(); properties.load(this.getClass().getClassLoader().getResourceAsStream(PHANTOMJS_DATA_FILE)); String name = properties.getProperty(this.getVersion().getDescription() + "." + this.getHostOs() + ".name"); String architecture = this.getArchitecture().indexOf("64") >= 0 ? "x86_64" : "i686"; LOGGER.debug("System Data: Arch [" + architecture + "] - OS [" + this.getHostOs() + "]"); if (this.getHostOs().equals("linux")) { name = String.format(name, architecture); }/*from w w w . ja v a 2 s . co m*/ // Download PhantomJS URL downloadPath = new URL(this.getDownloadUrl() + name); File phantomJsCompressedFile = new File(System.getProperty("java.io.tmpdir") + "/" + name); LOGGER.info("Downloading " + downloadPath.getPath() + " ..."); FileUtils.copyURLToFile(downloadPath, phantomJsCompressedFile); ArchiveInputStream archiveInputStream = null; if (phantomJsCompressedFile.getName().endsWith(".zip")) { archiveInputStream = new ZipArchiveInputStream(new FileInputStream(phantomJsCompressedFile)); } else if (phantomJsCompressedFile.getName().endsWith(".bz2")) { archiveInputStream = new TarArchiveInputStream( new BZip2CompressorInputStream(new FileInputStream(phantomJsCompressedFile))); } else if (phantomJsCompressedFile.getName().endsWith(".gz")) { archiveInputStream = new TarArchiveInputStream( new GzipCompressorInputStream(new FileInputStream(phantomJsCompressedFile))); } ArchiveEntry entry; while ((entry = archiveInputStream.getNextEntry()) != null) { if (entry.getName().endsWith(PHANTOMJS_DOWNLOAD_BINARY_PATH) || entry.getName().toLowerCase().endsWith("phantomjs.exe")) { // Create target folder new File(this.getTargetInstallationFolder() + "/" + this.getVersion().getDescription()).mkdirs(); FileUtils.forceMkdir(new File(binaryFile.getParent())); if (!binaryFile.exists()) { binaryFile.createNewFile(); } binaryFile.setExecutable(true); binaryFile.setReadable(true); // Untar the binary file FileOutputStream outputBinary = new FileOutputStream(binaryFile); LOGGER.info("Un-compress download to " + downloadPath.getPath() + " ..."); IOUtils.copy(archiveInputStream, outputBinary); outputBinary.close(); } } archiveInputStream.close(); }
From source file:io.snappydata.hydra.cluster.SnappyTest.java
protected void writeConfigData(String fileName, String logDir) { String filePath = productConfDirPath + fileName; File file = new File(filePath); if (fileName.equalsIgnoreCase("spark-env.sh")) file.setExecutable(true); Set<String> fileContent = new LinkedHashSet<String>(); fileContent = snappyTest.getFileContents(logDir, fileContent); if (fileContent.size() == 0) { String s = "No data found for writing to " + fileName + " file under conf directory"; throw new TestException(s); }/*from w w w . j a v a2 s . c o m*/ for (String s : fileContent) { snappyTest.writeToFile(s, file); } }
From source file:org.computeforcancer.android.client.Monitor.java
/** * Copies given file from APK assets to internal storage. * @param file name of file as it appears in assets directory * @param override define override, if already present in internal storage * @param executable set executable flag of file in internal storage * @return Boolean success//from w ww . j ava2 s. c o m */ private Boolean installFile(String file, Boolean override, Boolean executable) { Boolean success = false; byte[] b = new byte[1024]; int count; // If file is executable, cpu architecture has to be evaluated // and assets directory select accordingly String source = ""; if (executable) source = getAssestsDirForCpuArchitecture() + file; else source = file; try { if (Logging.ERROR) Log.d(Logging.TAG, "installing: " + source); File target = new File(boincWorkingDir + file); // Check path and create it File installDir = new File(boincWorkingDir); if (!installDir.exists()) { installDir.mkdir(); installDir.setWritable(true); } if (target.exists()) { if (override) target.delete(); else { if (Logging.DEBUG) Log.d(Logging.TAG, "skipped file, exists and ovverride is false"); return true; } } // Copy file from the asset manager to clientPath InputStream asset = getApplicationContext().getAssets().open(source); OutputStream targetData = new FileOutputStream(target); while ((count = asset.read(b)) != -1) { targetData.write(b, 0, count); } asset.close(); targetData.flush(); targetData.close(); success = true; //copy succeeded without exception // Set executable, if requested Boolean isExecutable = false; if (executable) { target.setExecutable(executable); isExecutable = target.canExecute(); success = isExecutable; // return false, if not executable } if (Logging.ERROR) Log.d(Logging.TAG, "install of " + source + " successfull. executable: " + executable + "/" + isExecutable); } catch (IOException e) { if (Logging.ERROR) Log.e(Logging.TAG, "IOException: " + e.getMessage()); if (Logging.ERROR) Log.d(Logging.TAG, "install of " + source + " failed."); } return success; }