List of usage examples for java.io File equals
public boolean equals(Object obj)
From source file:org.apache.maven.plugin.eclipse.EclipsePlugin.java
public final EclipseSourceDir[] buildDirectoryList(MavenProject project, File basedir, File buildOutputDirectory) throws MojoExecutionException { File projectBaseDir = project.getFile().getParentFile(); String mainOutput = IdeUtils.toRelativeAndFixSeparator(projectBaseDir, buildOutputDirectory, false); // If using the standard output location, don't mix the test output into it. String testOutput = null;//from w ww . j a va2 s . co m boolean useStandardOutputDir = buildOutputDirectory .equals(new File(project.getBuild().getOutputDirectory())); if (useStandardOutputDir) { getLog().debug("testOutput toRelativeAndFixSeparator " + projectBaseDir + " , " + project.getBuild().getTestOutputDirectory()); testOutput = IdeUtils.toRelativeAndFixSeparator(projectBaseDir, new File(project.getBuild().getTestOutputDirectory()), false); getLog().debug("testOutput after toRelative : " + testOutput); } Set mainDirectories = new LinkedHashSet(); extractSourceDirs(mainDirectories, project.getCompileSourceRoots(), basedir, projectBaseDir, false, null); extractResourceDirs(mainDirectories, project.getBuild().getResources(), basedir, projectBaseDir, false, mainOutput); Set testDirectories = new LinkedHashSet(); extractSourceDirs(testDirectories, project.getTestCompileSourceRoots(), basedir, projectBaseDir, true, testOutput); extractResourceDirs(testDirectories, project.getBuild().getTestResources(), basedir, projectBaseDir, true, testOutput); // avoid duplicated entries Set directories = new LinkedHashSet(); // NOTE: Since MNG-3118, test classes come before main classes boolean testBeforeMain = isMavenVersion("[2.0.8,)"); if (testBeforeMain) { directories.addAll(testDirectories); directories.removeAll(mainDirectories); directories.addAll(mainDirectories); } else { directories.addAll(mainDirectories); directories.addAll(testDirectories); } if (ajdt) extractAspectDirs(directories, project, basedir, projectBaseDir, testOutput); return (EclipseSourceDir[]) directories.toArray(new EclipseSourceDir[directories.size()]); }
From source file:org.moire.ultrasonic.service.DownloadServiceImpl.java
private synchronized void doPlay(final DownloadFile downloadFile, final int position, final boolean start) { try {/* ww w .ja v a 2 s . c om*/ downloadFile.setPlaying(false); //downloadFile.setPlaying(true); final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile(); boolean partial = file.equals(downloadFile.getPartialFile()); downloadFile.updateModificationDate(); mediaPlayer.setOnCompletionListener(null); secondaryProgress = -1; // Ensure seeking in non StreamProxy playback works mediaPlayer.reset(); setPlayerState(IDLE); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); String dataSource = file.getPath(); if (partial) { if (proxy == null) { proxy = new StreamProxy(this); proxy.start(); } dataSource = String.format("http://127.0.0.1:%d/%s", proxy.getPort(), URLEncoder.encode(dataSource, Constants.UTF_8)); Log.i(TAG, String.format("Data Source: %s", dataSource)); } else if (proxy != null) { proxy.stop(); proxy = null; } Log.i(TAG, "Preparing media player"); mediaPlayer.setDataSource(dataSource); setPlayerState(PREPARING); mediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() { @Override public void onBufferingUpdate(MediaPlayer mp, int percent) { SeekBar progressBar = DownloadActivity.getProgressBar(); MusicDirectory.Entry song = downloadFile.getSong(); if (percent == 100) { if (progressBar != null) { progressBar.setSecondaryProgress(100 * progressBar.getMax()); } mp.setOnBufferingUpdateListener(null); } else if (progressBar != null && song.getTranscodedContentType() == null && Util.getMaxBitRate(DownloadServiceImpl.this) == 0) { secondaryProgress = (int) (((double) percent / (double) 100) * progressBar.getMax()); progressBar.setSecondaryProgress(secondaryProgress); } } }); mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { Log.i(TAG, "Media player prepared"); setPlayerState(PREPARED); SeekBar progressBar = DownloadActivity.getProgressBar(); if (progressBar != null && downloadFile.isWorkDone()) { // Populate seek bar secondary progress if we have a complete file for consistency DownloadActivity.getProgressBar().setSecondaryProgress(100 * progressBar.getMax()); } synchronized (DownloadServiceImpl.this) { if (position != 0) { Log.i(TAG, String.format("Restarting player from position %d", position)); seekTo(position); } cachedPosition = position; if (start) { mediaPlayer.start(); setPlayerState(STARTED); } else { setPlayerState(PAUSED); } } lifecycleSupport.serializeDownloadQueue(); } }); setupHandlers(downloadFile, partial); mediaPlayer.prepareAsync(); } catch (Exception x) { handleError(x); } }
From source file:SWTFileViewerDemo.java
/** * Notifies the application components that a new current directory has been * selected/*from ww w. ja v a2s. co m*/ * * @param dir * the directory that was selected, null is ignored */ void notifySelectedDirectory(File dir) { if (dir == null) return; if (currentDirectory != null && dir.equals(currentDirectory)) return; currentDirectory = dir; notifySelectedFiles(null); /* * Shell: Sets the title to indicate the selected directory */ shell.setText(getResourceString("Title", new Object[] { currentDirectory.getPath() })); /* * Table view: Displays the contents of the selected directory. */ workerUpdate(dir, false); /* * Combo view: Sets the combo box to point to the selected directory. */ final File[] comboRoots = (File[]) combo.getData(COMBODATA_ROOTS); int comboEntry = -1; if (comboRoots != null) { for (int i = 0; i < comboRoots.length; ++i) { if (dir.equals(comboRoots[i])) { comboEntry = i; break; } } } if (comboEntry == -1) combo.setText(dir.getPath()); else combo.select(comboEntry); /* * Tree view: If not already expanded, recursively expands the parents * of the specified directory until it is visible. */ Vector /* of File */ path = new Vector(); // Build a stack of paths from the root of the tree while (dir != null) { path.add(dir); dir = dir.getParentFile(); } // Recursively expand the tree to get to the specified directory TreeItem[] items = tree.getItems(); TreeItem lastItem = null; for (int i = path.size() - 1; i >= 0; --i) { final File pathElement = (File) path.elementAt(i); // Search for a particular File in the array of tree items // No guarantee that the items are sorted in any recognizable // fashion, so we'll // just sequential scan. There shouldn't be more than a few thousand // entries. TreeItem item = null; for (int k = 0; k < items.length; ++k) { item = items[k]; if (item.isDisposed()) continue; final File itemFile = (File) item.getData(TREEITEMDATA_FILE); if (itemFile != null && itemFile.equals(pathElement)) break; } if (item == null) break; lastItem = item; if (i != 0 && !item.getExpanded()) { treeExpandItem(item); item.setExpanded(true); } items = item.getItems(); } tree.setSelection((lastItem != null) ? new TreeItem[] { lastItem } : new TreeItem[0]); }
From source file:SWTFileViewerDemo.java
/** * Handles a drop on a dropTarget.// ww w .java 2 s . c o m * <p> * Used in drop().<br> * Note event.detail is modified by this method. * </p> * * @param event * the DropTargetEvent passed as parameter to the drop() method * @param targetFile * the File representing the drop target location under * inspection, or null if none */ private void dropTargetHandleDrop(DropTargetEvent event, File targetFile) { // Get dropped data (an array of filenames) if (!dropTargetValidate(event, targetFile)) return; final String[] sourceNames = (String[]) event.data; if (sourceNames == null) event.detail = DND.DROP_NONE; if (event.detail == DND.DROP_NONE) return; // Open progress dialog progressDialog = new ProgressDialog(shell, (event.detail == DND.DROP_MOVE) ? ProgressDialog.MOVE : ProgressDialog.COPY); progressDialog.setTotalWorkUnits(sourceNames.length); progressDialog.open(); // Copy each file Vector /* of File */ processedFiles = new Vector(); for (int i = 0; (i < sourceNames.length) && (!progressDialog.isCancelled()); i++) { final File source = new File(sourceNames[i]); final File dest = new File(targetFile, source.getName()); if (source.equals(dest)) continue; // ignore if in same location progressDialog.setDetailFile(source, ProgressDialog.COPY); while (!progressDialog.isCancelled()) { if (copyFileStructure(source, dest)) { processedFiles.add(source); break; } else if (!progressDialog.isCancelled()) { if (event.detail == DND.DROP_MOVE && (!isDragging)) { // It is not possible to notify an external drag source // that a drop // operation was only partially successful. This is // particularly a // problem for DROP_MOVE operations since unless the // source gets // DROP_NONE, it will delete the original data including // bits that // may not have been transferred successfully. MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.RETRY | SWT.CANCEL); box.setText(getResourceString("dialog.FailedCopy.title")); box.setMessage( getResourceString("dialog.FailedCopy.description", new Object[] { source, dest })); int button = box.open(); if (button == SWT.CANCEL) { i = sourceNames.length; event.detail = DND.DROP_NONE; break; } } else { // We can recover gracefully from errors if the drag // source belongs // to this application since it will look at // processedDropFiles. MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.ABORT | SWT.RETRY | SWT.IGNORE); box.setText(getResourceString("dialog.FailedCopy.title")); box.setMessage( getResourceString("dialog.FailedCopy.description", new Object[] { source, dest })); int button = box.open(); if (button == SWT.ABORT) i = sourceNames.length; if (button != SWT.RETRY) break; } } progressDialog.addProgress(1); } } if (isDragging) { // Remember exactly which files we processed processedDropFiles = ((File[]) processedFiles.toArray(new File[processedFiles.size()])); } else { progressDialog.close(); progressDialog = null; } notifyRefreshFiles(new File[] { targetFile }); }
From source file:org.pentaho.platform.repository.solution.filebased.FileBasedSolutionRepository.java
protected String getLocaleString(final String key, String baseName, final ISolutionFile baseFile) { File searchDir = ((FileSolutionFile) baseFile.retrieveParent()).getFile(); try {// w w w . ja va 2 s . c o m boolean searching = true; while (searching) { // look to see if this exists URLClassLoader loader = new URLClassLoader(new URL[] { searchDir.toURL() }, null); String localeText = null; try { ResourceBundle rb = ResourceBundle.getBundle(baseName, getLocale(), loader); localeText = rb.getString(key.substring(1)); } catch (Exception e) { // couldn't load bundle, move along } if (localeText != null) { return localeText; } // if we get to here, we couldn't use the resource bundle to find the string, so we will use this another approach // change the basename to messages (messages.properties) and go up a directory in our searching if (searching) { if (!baseName.equals("messages")) { //$NON-NLS-1$ baseName = "messages"; //$NON-NLS-1$ } else { if (searchDir.equals(rootFile)) { searching = false; } else { searchDir = searchDir.getParentFile(); } } } } return null; } catch (Exception e) { error(Messages.getErrorString("SolutionRepository.ERROR_0007_COULD_NOT_READ_PROPERTIES", //$NON-NLS-1$ baseFile.getFullPath()), e); } return null; }
From source file:org.codehaus.enunciate.modules.gwt.GWTDeploymentModule.java
/** * Invokes GWTCompile on the apps specified in the configuration file. *//*from ww w. j a v a 2 s. c om*/ protected void doGWTCompile() throws EnunciateException, IOException { if (this.gwtHome == null) { throw new EnunciateException( "To compile a GWT app you must specify the GWT home directory, either in configuration, by setting the GWT_HOME environment variable, or setting the 'gwt.home' system property."); } File gwtHomeDir = new File(this.gwtHome); if (!gwtHomeDir.exists()) { throw new EnunciateException("GWT home not found ('" + gwtHomeDir.getAbsolutePath() + "')."); } File gwtUserJar = new File(gwtHomeDir, "gwt-user.jar"); if (!gwtUserJar.exists()) { warn("Unable to find %s. You may be GWT compile errors.", gwtUserJar.getAbsolutePath()); } //now we have to find gwt-dev.jar. //start by assuming linux... File gwtDevJar = new File(gwtHomeDir, "gwt-dev.jar"); if (!gwtDevJar.exists()) { File linuxDevJar = new File(gwtHomeDir, "gwt-dev-linux.jar"); gwtDevJar = linuxDevJar; if (!gwtDevJar.exists()) { //linux not found. try mac... File macDevJar = new File(gwtHomeDir, "gwt-dev-mac.jar"); gwtDevJar = macDevJar; if (!gwtDevJar.exists()) { //okay, we'll try windows if we have to... File windowsDevJar = new File(gwtHomeDir, "gwt-dev-windows.jar"); gwtDevJar = windowsDevJar; if (!gwtDevJar.exists()) { throw new EnunciateException( String.format("Unable to find GWT dev jar. Looked for %s, %s, and %s.", linuxDevJar.getAbsolutePath(), macDevJar.getAbsolutePath(), windowsDevJar.getAbsolutePath())); } } } } boolean windows = false; File javaBinDir = new File(System.getProperty("java.home"), "bin"); File javaExecutable = new File(javaBinDir, "java"); if (!javaExecutable.exists()) { //append the "exe" for windows users. javaExecutable = new File(javaBinDir, "java.exe"); windows = true; } String javaCommand = javaExecutable.getAbsolutePath(); if (!javaExecutable.exists()) { warn("No java executable found in %s. We'll just hope the environment is set up to execute 'java'...", javaBinDir.getAbsolutePath()); javaCommand = "java"; } StringBuilder classpath = new StringBuilder(enunciate.getEnunciateRuntimeClasspath()); //append the client-side gwt directory. classpath.append(File.pathSeparatorChar).append(getClientSideGenerateDir().getAbsolutePath()); //append the gwt-user jar. classpath.append(File.pathSeparatorChar).append(gwtUserJar.getAbsolutePath()); //append the gwt-dev jar. classpath.append(File.pathSeparatorChar).append(gwtDevJar.getAbsolutePath()); //so here's the GWT compile command: //java [extra jvm args] -cp [classpath] [compilerClass] -gen [gwt-gen-dir] -style [style] -out [out] [moduleName] List<String> jvmargs = getGwtCompileJVMArgs(); List<String> compilerArgs = getGwtCompilerArgs(); List<String> gwtcCommand = new ArrayList<String>(jvmargs.size() + compilerArgs.size() + 11); int argIndex = 0; gwtcCommand.add(argIndex++, javaCommand); for (String arg : jvmargs) { gwtcCommand.add(argIndex++, arg); } gwtcCommand.add(argIndex++, "-cp"); int classpathArgIndex = argIndex; //app-specific arg. gwtcCommand.add(argIndex++, null); int compileClassIndex = argIndex; gwtcCommand.add(argIndex++, getGwtCompilerClass()); gwtcCommand.add(argIndex++, "-gen"); gwtcCommand.add(argIndex++, getGwtGenDir().getAbsolutePath()); gwtcCommand.add(argIndex++, "-style"); int styleArgIndex = argIndex; gwtcCommand.add(argIndex++, null); //app-specific arg. gwtcCommand.add(argIndex++, gwtVersionGreaterThan(1, 5) ? "-war" : "-out"); int outArgIndex = argIndex; gwtcCommand.add(argIndex++, null); //app-specific arg. for (String arg : compilerArgs) { gwtcCommand.add(argIndex++, arg); } int moduleNameIndex = argIndex; gwtcCommand.add(argIndex, null); //module-specific arg. for (GWTApp gwtApp : gwtApps) { String appName = gwtApp.getName(); File appSource = enunciate.resolvePath(gwtApp.getSrcDir()); String style = gwtApp.getJavascriptStyle().toString(); File appDir = getAppGenerateDir(appName); gwtcCommand.set(classpathArgIndex, classpath.toString() + File.pathSeparatorChar + appSource.getAbsolutePath()); gwtcCommand.set(styleArgIndex, style); gwtcCommand.set(outArgIndex, appDir.getAbsolutePath()); boolean upToDate = enunciate.isUpToDate(getClientSideGenerateDir(), appDir) && enunciate.isUpToDate(appSource, appDir); if (!upToDate) { for (GWTAppModule appModule : gwtApp.getModules()) { String moduleName = appModule.getName(); gwtcCommand.set(moduleNameIndex, moduleName); debug("Executing GWTCompile for module '%s'...", moduleName); if (enunciate.isDebug()) { StringBuilder command = new StringBuilder(); for (String commandPiece : gwtcCommand) { command.append(' ').append(commandPiece); } debug("Executing GWTCompile for module %s with the command: %s", moduleName, command); } ProcessBuilder processBuilder = new ProcessBuilder(gwtcCommand); processBuilder.directory(getGenerateDir()); processBuilder.redirectErrorStream(true); Process process = processBuilder.start(); BufferedReader procReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = procReader.readLine(); while (line != null) { line = URLDecoder.decode(line, "utf-8").replaceAll("%", "%%").trim(); //GWT URL-encodes spaces and other weird Windows characters. info(line); line = procReader.readLine(); } int procCode; try { procCode = process.waitFor(); } catch (InterruptedException e1) { throw new EnunciateException("Unexpected inturruption of the GWT compile process."); } if (procCode != 0) { throw new EnunciateException("GWT compile failed for module " + moduleName); } if (!gwtVersionGreaterThan(1, 5)) { File moduleOutputDir = appDir; String outputPath = appModule.getOutputPath(); if ((outputPath != null) && (!"".equals(outputPath.trim()))) { moduleOutputDir = new File(appDir, outputPath); } File moduleGenDir = new File(appDir, moduleName); if (!moduleOutputDir.equals(moduleGenDir)) { moduleOutputDir.mkdirs(); enunciate.copyDir(moduleGenDir, moduleOutputDir); deleteDir(moduleGenDir); } } StringBuilder shellCommand = new StringBuilder(); for (int i = 0; i < moduleNameIndex; i++) { String commandArg = gwtcCommand.get(i); if (i == compileClassIndex) { commandArg = gwtVersionGreaterThan(1, 5) ? "com.google.gwt.dev.HostedMode" : "com.google.gwt.dev.GWTShell"; } else if (commandArg.indexOf(' ') >= 0) { commandArg = '"' + commandArg + '"'; } shellCommand.append(commandArg).append(' '); } //add any extra args before the module name. shellCommand.append(windows ? "%*" : "$@").append(' '); String shellPage = getModuleId(moduleName) + ".html"; if (appModule.getShellPage() != null) { shellPage = appModule.getShellPage(); } if (!gwtVersionGreaterThan(1, 5)) { //when invoking the shell for GWT 1.4 or 1.5, it requires a URL to load. //The URL is the [moduleName]/[shellPage.html] shellCommand.append(moduleName).append('/').append(shellPage); } else { //as of 1.6, you invoke it with -startupUrl [shellPage.html] [moduleName] shellCommand.append("-startupUrl ").append(shellPage).append(' ').append(moduleName); } File scriptFile = getShellScriptFile(appName, moduleName); scriptFile.getParentFile().mkdirs(); FileWriter writer = new FileWriter(scriptFile); writer.write(shellCommand.toString()); writer.flush(); writer.close(); File shellFile = getShellScriptFile(appName, moduleName); if (shellFile.exists()) { StringBuilder scriptArtifactId = new StringBuilder(); if ((appName != null) && (appName.trim().length() > 0)) { scriptArtifactId.append(appName).append('.'); } scriptArtifactId.append(moduleName).append(".shell"); getEnunciate() .addArtifact(new FileArtifact(getName(), scriptArtifactId.toString(), shellFile)); } else { debug("No GWT shell script file exists at %s. No artifact added.", shellFile); } } } else { info("Skipping GWT compile for app %s as everything appears up-to-date...", appName); } } }
From source file:org.jahia.services.templates.SourceControlHelper.java
public JCRNodeWrapper checkoutModule(final File moduleSources, final String scmURI, final String branchOrTag, final String moduleId, final String version, final JCRSessionWrapper session) throws IOException, RepositoryException, BundleException { boolean newModule = moduleSources == null; File sources = ensureModuleSourceFolder(moduleSources); try {/*ww w.j a v a 2 s.c om*/ // checkout sources from SCM SourceControlManagement scm = sourceControlFactory.checkoutRepository(sources, scmURI, branchOrTag, false); // verify the sources and found out module information ModuleInfo moduleInfo = getModuleInfo(sources, scmURI, moduleId, version, branchOrTag); if (templatePackageRegistry.containsId(moduleInfo.id) && !moduleInfo.groupId.equals(templatePackageRegistry.lookupById(moduleInfo.id).getGroupId())) { FileUtils.deleteDirectory(sources); throw new ScmUnavailableModuleIdException("Cannot checkout module " + moduleInfo.id + " because another module with the same artifactId exists", moduleInfo.id); } if (version != null && !version.equals(moduleInfo.version)) { FileUtils.deleteDirectory(sources); throw new ScmWrongVersionException("Sources don't match module version"); } if (newModule) { File newPath = new File(sources.getParentFile(), moduleInfo.id + "_" + moduleInfo.version); int i = 0; while (newPath.exists()) { newPath = new File(sources.getParentFile(), moduleInfo.id + "_" + moduleInfo.version + "_" + (++i)); } FileUtils.moveDirectory(sources, newPath); moduleInfo.path = new File(moduleInfo.path.getPath().replace(sources.getPath(), newPath.getPath())); sources = newPath; scm = sourceControlFactory.getSourceControlManagement(moduleInfo.path); } if (sources.equals(moduleInfo.path)) { setSCMConfigInPom(sources, scmURI); } JahiaTemplatesPackage pack = ServicesRegistry.getInstance().getJahiaTemplateManagerService() .compileAndDeploy(moduleInfo.id, moduleInfo.path, session); if (pack != null) { JCRNodeWrapper node = session.getNode("/modules/" + pack.getIdWithVersion()); pack.setSourceControl(scm); setSourcesFolderInPackageAndNode(pack, moduleInfo.path, node); session.save(); // flush resource bundle cache ResourceBundles.flushCache(); NodeTypeRegistry.getInstance().flushLabels(); return node; } else { FileUtils.deleteDirectory(sources); } } catch (BundleException e) { FileUtils.deleteQuietly(sources); throw e; } catch (RepositoryException e) { FileUtils.deleteQuietly(sources); throw e; } catch (IOException e) { FileUtils.deleteQuietly(sources); throw e; } catch (DocumentException e) { FileUtils.deleteQuietly(sources); throw new IOException(e); } catch (XmlPullParserException e) { FileUtils.deleteQuietly(sources); throw new IOException(e); } return null; }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipsePlugin.java
private void extractSourceDirs(Set directories, List sourceRoots, File basedir, File projectBaseDir, boolean test, String output) throws MojoExecutionException { for (Iterator it = sourceRoots.iterator(); it.hasNext();) { File sourceRootFile = new File((String) it.next()); if (sourceRootFile.isDirectory()) { String sourceRoot = IdeUtils.toRelativeAndFixSeparator(projectBaseDir, sourceRootFile, !projectBaseDir.equals(basedir)); directories.add(new EclipseSourceDir(sourceRoot, output, false, test, sourceIncludes, sourceExcludes, false)); }// w w w . j a v a 2s .c o m } }
From source file:SWTFileViewerDemo.java
/** * Copies a file or entire directory structure. * //from w ww . j ava 2 s . com * @param oldFile * the location of the old file or directory * @param newFile * the location of the new file or directory * @return true iff the operation succeeds without errors */ boolean copyFileStructure(File oldFile, File newFile) { if (oldFile == null || newFile == null) return false; // ensure that newFile is not a child of oldFile or a dupe File searchFile = newFile; do { if (oldFile.equals(searchFile)) return false; searchFile = searchFile.getParentFile(); } while (searchFile != null); if (oldFile.isDirectory()) { /* * Copy a directory */ if (progressDialog != null) { progressDialog.setDetailFile(oldFile, ProgressDialog.COPY); } if (simulateOnly) { // System.out.println(getResourceString("simulate.DirectoriesCreated.text", // new Object[] { newFile.getPath() })); } else { if (!newFile.mkdirs()) return false; } File[] subFiles = oldFile.listFiles(); if (subFiles != null) { if (progressDialog != null) { progressDialog.addWorkUnits(subFiles.length); } for (int i = 0; i < subFiles.length; i++) { File oldSubFile = subFiles[i]; File newSubFile = new File(newFile, oldSubFile.getName()); if (!copyFileStructure(oldSubFile, newSubFile)) return false; if (progressDialog != null) { progressDialog.addProgress(1); if (progressDialog.isCancelled()) return false; } } } } else { /* * Copy a file */ if (simulateOnly) { // System.out.println(getResourceString("simulate.CopyFromTo.text", // new Object[] { oldFile.getPath(), newFile.getPath() })); } else { FileReader in = null; FileWriter out = null; try { in = new FileReader(oldFile); out = new FileWriter(newFile); int count; while ((count = in.read()) != -1) out.write(count); } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } finally { try { if (in != null) in.close(); if (out != null) out.close(); } catch (IOException e) { return false; } } } } return true; }