/** * Recursively scans given directory and load all found files by loader. * * @param clsLdr Loader that could load class from given file. * @param dir Directory which should be scanned. * @param rsrcs Set which will be filled in. */ @SuppressWarnings({"UnusedCatchParameter"}) private static void findResourcesInDirectory( GridUriDeploymentFileResourceLoader clsLdr, File dir, Set<Class<? extends GridTask<?, ?>>> rsrcs) { assert dir.isDirectory() == true; for (File file : dir.listFiles()) { if (file.isDirectory()) { // Recurse down into directories. findResourcesInDirectory(clsLdr, file, rsrcs); } else { Class<? extends GridTask<?, ?>> rsrc = null; try { rsrc = clsLdr.createResource(file.getAbsolutePath(), true); } catch (GridSpiException e) { // Must never happen because we use 'ignoreUnknownRsrc=true'. assert false; } if (rsrc != null) { rsrcs.add(rsrc); } } } }
/** * Extracts next entry from JAR file, creating directories as needed. If the entry is for a * directory which doesn't exist prior to this invocation, returns that entry, otherwise returns * null. */ ZipEntry extractFile(InputStream is, ZipEntry e) throws IOException { ZipEntry rc = null; String name = e.getName(); File f = new File(e.getName().replace('/', File.separatorChar)); if (e.isDirectory()) { if (f.exists()) { if (!f.isDirectory()) { throw new IOException(formatMsg("error.create.dir", f.getPath())); } } else { if (!f.mkdirs()) { throw new IOException(formatMsg("error.create.dir", f.getPath())); } else { rc = e; } } if (vflag) { output(formatMsg("out.create", name)); } } else { if (f.getParent() != null) { File d = new File(f.getParent()); if (!d.exists() && !d.mkdirs() || !d.isDirectory()) { throw new IOException(formatMsg("error.create.dir", d.getPath())); } } try { copy(is, f); } finally { if (is instanceof ZipInputStream) ((ZipInputStream) is).closeEntry(); else is.close(); } if (vflag) { if (e.getMethod() == ZipEntry.DEFLATED) { output(formatMsg("out.inflated", name)); } else { output(formatMsg("out.extracted", name)); } } } if (!useExtractionTime) { long lastModified = e.getTime(); if (lastModified != -1) { f.setLastModified(lastModified); } } return rc; }
public static void testBump() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("p1"); int size = project.getProperties().size(); Version old = new Version(project.getProperty("Bundle-Version")); System.err.println("Old version " + old); project.bump("=+0"); Version newv = new Version(project.getProperty("Bundle-Version")); System.err.println("New version " + newv); assertEquals(old.getMajor(), newv.getMajor()); assertEquals(old.getMinor() + 1, newv.getMinor()); assertEquals(0, newv.getMicro()); assertEquals(size, project.getProperties().size()); assertEquals("sometime", newv.getQualifier()); } finally { IO.deleteWithException(tmp); } }
/** * Expands list of files to process into full list of all files that can be found by recursively * descending directories. */ void expand(File dir, String[] files, boolean isUpdate) { if (files == null) { return; } for (int i = 0; i < files.length; i++) { File f; if (dir == null) { f = new File(files[i]); } else { f = new File(dir, files[i]); } if (f.isFile()) { if (entries.add(f)) { if (isUpdate) entryMap.put(entryName(f.getPath()), f); } } else if (f.isDirectory()) { if (entries.add(f)) { if (isUpdate) { String dirPath = f.getPath(); dirPath = (dirPath.endsWith(File.separator)) ? dirPath : (dirPath + File.separator); entryMap.put(entryName(dirPath), f); } expand(f, f.list(), isUpdate); } } else { error(formatMsg("error.nosuch.fileordir", String.valueOf(f))); ok = false; } } }
public static void testBumpIncludeFile() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("bump-included"); project.setTrace(true); Version old = new Version(project.getProperty("Bundle-Version")); assertEquals(new Version(1, 0, 0), old); project.bump("=+0"); Processor processor = new Processor(); processor.setProperties(project.getFile("include.txt")); Version newv = new Version(processor.getProperty("Bundle-Version")); System.err.println("New version " + newv); assertEquals(1, newv.getMajor()); assertEquals(1, newv.getMinor()); assertEquals(0, newv.getMicro()); } finally { IO.deleteWithException(tmp); } }
public static void testBumpSubBuilders() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("bump-sub"); project.setTrace(true); assertNull(project.getProperty("Bundle-Version")); project.bump("=+0"); assertNull(project.getProperty("Bundle-Version")); for (Builder b : project.getSubBuilders()) { assertEquals(new Version(1, 1, 0), new Version(b.getVersion())); } } finally { IO.deleteWithException(tmp); } }
/** * Load classes from given file. File could be either directory or JAR file. * * @param clsLdr Class loader to load files. * @param file Either directory or JAR file which contains classes or references to them. * @return Set of found and loaded classes or empty set if file does not exist. * @throws GridSpiException Thrown if given JAR file references to none existed class or * IOException occurred during processing. */ static Set<Class<? extends GridTask<?, ?>>> getClasses(ClassLoader clsLdr, File file) throws GridSpiException { Set<Class<? extends GridTask<?, ?>>> rsrcs = new HashSet<Class<? extends GridTask<?, ?>>>(); if (file.exists() == false) { return rsrcs; } GridUriDeploymentFileResourceLoader fileRsrcLdr = new GridUriDeploymentFileResourceLoader(clsLdr, file); if (file.isDirectory()) { findResourcesInDirectory(fileRsrcLdr, file, rsrcs); } else { try { for (JarEntry entry : U.asIterable(new JarFile(file.getAbsolutePath()).entries())) { Class<? extends GridTask<?, ?>> rsrc = fileRsrcLdr.createResource(entry.getName(), false); if (rsrc != null) { rsrcs.add(rsrc); } } } catch (IOException e) { throw new GridSpiException( "Failed to discover classes in file: " + file.getAbsolutePath(), e); } } return rsrcs; }
protected void addPathFile(final File pathComponent) throws IOException { if (!this.pathComponents.contains(pathComponent)) { this.pathComponents.addElement(pathComponent); } if (pathComponent.isDirectory()) { return; } final String absPathPlusTimeAndLength = pathComponent.getAbsolutePath() + pathComponent.lastModified() + "-" + pathComponent.length(); String classpath = AntClassLoader.pathMap.get(absPathPlusTimeAndLength); if (classpath == null) { JarFile jarFile = null; try { jarFile = new JarFile(pathComponent); final Manifest manifest = jarFile.getManifest(); if (manifest == null) { return; } classpath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); } finally { if (jarFile != null) { jarFile.close(); } } if (classpath == null) { classpath = ""; } AntClassLoader.pathMap.put(absPathPlusTimeAndLength, classpath); } if (!"".equals(classpath)) { final URL baseURL = AntClassLoader.FILE_UTILS.getFileURL(pathComponent); final StringTokenizer st = new StringTokenizer(classpath); while (st.hasMoreTokens()) { final String classpathElement = st.nextToken(); final URL libraryURL = new URL(baseURL, classpathElement); if (!libraryURL.getProtocol().equals("file")) { this.log( "Skipping jar library " + classpathElement + " since only relative URLs are supported by this" + " loader", 3); } else { final String decodedPath = Locator.decodeUri(libraryURL.getFile()); final File libraryFile = new File(decodedPath); if (!libraryFile.exists() || this.isInPath(libraryFile)) { continue; } this.addPathFile(libraryFile); } } } }
private Manifest getJarManifest(final File container) throws IOException { if (container.isDirectory()) { return null; } final JarFile jarFile = this.jarFiles.get(container); if (jarFile == null) { return null; } return jarFile.getManifest(); }
/** * scans for possible help directories (languages) * * @return a list of possible language directories */ public List<String> getLanguages() { List<String> paths = new ArrayList<>(); URL home = getClass().getResource(".."); File local; if (home != null) { System.out.println("looks like you are not starting from a jar-package"); try { local = new File(new File(home.getPath()).getParentFile().getParentFile(), helproot); System.out.println("local: " + local.getAbsolutePath()); for (File s : local.listFiles()) { if (s.isDirectory() && (s.listFiles().length > 0)) { addToList(paths, s.getName()); } } } catch (Exception e) { System.out.println("but not loading from the developer workbench?!"); } } else { System.out.println("looks like you are starting from a jar-package"); local = CommandLoader.getLocation(); File helpDir = new File(local, helproot); if (helpDir.exists() && helpDir.isDirectory() && (helpDir.listFiles().length > 0)) { for (File s : helpDir.listFiles()) { if (s.isDirectory()) { addToList(paths, s.getName()); } } } File jar = new File(CommandLoader.classPath()); for (File file : local.listFiles()) { try { if (!jar.getCanonicalPath().equals(file.getCanonicalPath())) { searchJarPath(file, paths); } } catch (IOException ignored) { } searchJarPath(jar, paths); } } return paths; }
private Certificate[] getCertificates(final File container, final String entry) throws IOException { if (container.isDirectory()) { return null; } final JarFile jarFile = this.jarFiles.get(container); if (jarFile == null) { return null; } final JarEntry ent = jarFile.getJarEntry(entry); return (Certificate[]) ((ent == null) ? null : ent.getCertificates()); }
/** Adds a new file entry to the ZIP output stream. */ void addFile(ZipOutputStream zos, File file) throws IOException { String name = file.getPath(); boolean isDir = file.isDirectory(); if (isDir) { name = name.endsWith(File.separator) ? name : (name + File.separator); } name = entryName(name); if (name.equals("") || name.equals(".") || name.equals(zname)) { return; } else if ((name.equals(MANIFEST_DIR) || name.equals(MANIFEST_NAME)) && !Mflag) { if (vflag) { output(formatMsg("out.ignore.entry", name)); } return; } long size = isDir ? 0 : file.length(); if (vflag) { out.print(formatMsg("out.adding", name)); } ZipEntry e = new ZipEntry(name); e.setTime(file.lastModified()); if (size == 0) { e.setMethod(ZipEntry.STORED); e.setSize(0); e.setCrc(0); } else if (flag0) { crc32File(e, file); } zos.putNextEntry(e); if (!isDir) { copy(file, zos); } zos.closeEntry(); /* report how much compression occurred. */ if (vflag) { size = e.getSize(); long csize = e.getCompressedSize(); out.print(formatMsg2("out.size", String.valueOf(size), String.valueOf(csize))); if (e.getMethod() == ZipEntry.DEFLATED) { long ratio = 0; if (size != 0) { ratio = ((size - csize) * 100) / size; } output(formatMsg("out.deflated", String.valueOf(ratio))); } else { output(getMsg("out.stored")); } } }
private static void scanDir(File dir, String prefix, Set<String> names) throws Exception { File[] files = dir.listFiles(); if (files == null) return; for (int i = 0; i < files.length; i++) { File f = files[i]; String name = f.getName(); String p = (prefix.equals("")) ? name : prefix + "." + name; if (f.isDirectory()) scanDir(f, p, names); else if (name.endsWith(".class")) { p = p.substring(0, p.length() - 6); names.add(p); } } }
/** * Enumerates the resouces in a give package name. This works even if the resources are loaded * from a jar file! * * <p>Adapted from code by mikewse on the java.sun.com message boards. * http://forum.java.sun.com/thread.jsp?forum=22&thread=30984 * * @param packageName The package to enumerate * @return A Set of Strings for each resouce in the package. */ public static Set getResoucesInPackage(String packageName) throws IOException { String localPackageName; if (packageName.endsWith("/")) { localPackageName = packageName; } else { localPackageName = packageName + '/'; } Enumeration dirEnum = ClassLoader.getSystemResources(localPackageName); Set names = new HashSet(); // Loop CLASSPATH directories while (dirEnum.hasMoreElements()) { URL resUrl = (URL) dirEnum.nextElement(); // Pointing to filesystem directory if (resUrl.getProtocol().equals("file")) { File dir = new File(resUrl.getFile()); File[] files = dir.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) continue; names.add(localPackageName + file.getName()); } } // Pointing to Jar file } else if (resUrl.getProtocol().equals("jar")) { JarURLConnection jconn = (JarURLConnection) resUrl.openConnection(); JarFile jfile = jconn.getJarFile(); Enumeration entryEnum = jfile.entries(); while (entryEnum.hasMoreElements()) { JarEntry entry = (JarEntry) entryEnum.nextElement(); String entryName = entry.getName(); // Exclude our own directory if (entryName.equals(localPackageName)) continue; String parentDirName = entryName.substring(0, entryName.lastIndexOf('/') + 1); if (!parentDirName.equals(localPackageName)) continue; names.add(entryName); } } else { // Invalid classpath entry } } return names; }
public static boolean deleteAll(File file) { boolean b = true; if ((file != null) && file.exists()) { if (file.isDirectory()) { try { File[] files = file.listFiles(); for (File f : files) b &= deleteAll(f); } catch (Exception e) { return false; } } b &= file.delete(); } return b; }
/** * load a specified directory filled with help files (outside a jar) * * @param local the directory */ private void initFile(File local) { if (!local.exists()) { return; } int counter = 0; if (local.isDirectory()) { for (File file : local.listFiles()) { if (file.getName().toLowerCase().endsWith(".htm") && file.isFile()) { String mnemo = file.getName().toLowerCase().replace(".htm", ""); if (!exists(mnemo)) { addToCache(file, mnemo); counter++; } } } } try { System.out.println( "+ " + String.valueOf(counter) + "\thelp text(s) from:\t" + local.getCanonicalPath()); } catch (IOException ignored) { } }
protected URL getResourceURL(final File file, final String resourceName) { try { JarFile jarFile = this.jarFiles.get(file); if (jarFile == null && file.isDirectory()) { final File resource = new File(file, resourceName); if (resource.exists()) { try { return AntClassLoader.FILE_UTILS.getFileURL(resource); } catch (MalformedURLException ex) { return null; } } } else { if (jarFile == null) { if (!file.exists()) { return null; } jarFile = new JarFile(file); this.jarFiles.put(file, jarFile); jarFile = this.jarFiles.get(file); } final JarEntry entry = jarFile.getJarEntry(resourceName); if (entry != null) { try { return new URL("jar:" + AntClassLoader.FILE_UTILS.getFileURL(file) + "!/" + entry); } catch (MalformedURLException ex) { return null; } } } } catch (Exception e) { final String msg = "Unable to obtain resource from " + file + ": "; this.log(msg + e, 1); System.err.println(msg); e.printStackTrace(); } return null; }
private InputStream getResourceStream(final File file, final String resourceName) { try { JarFile jarFile = this.jarFiles.get(file); if (jarFile == null && file.isDirectory()) { final File resource = new File(file, resourceName); if (resource.exists()) { return new FileInputStream(resource); } } else { if (jarFile == null) { if (!file.exists()) { return null; } jarFile = new JarFile(file); this.jarFiles.put(file, jarFile); jarFile = this.jarFiles.get(file); } final JarEntry entry = jarFile.getJarEntry(resourceName); if (entry != null) { return jarFile.getInputStream(entry); } } } catch (Exception e) { this.log( "Ignoring Exception " + e.getClass().getName() + ": " + e.getMessage() + " reading resource " + resourceName + " from " + file, 3); } return null; }
private static String validateLogFile(String logFileName, String scriptName) { String strippedDownScriptName = null; if (scriptName != null) { File scriptFile = new File(scriptName); if (!scriptFile.isDirectory()) { String scriptFileAbsPath; try { scriptFileAbsPath = scriptFile.getCanonicalPath(); } catch (IOException ioe) { throw new AssertionError( "Could not compute canonical path to the script file " + ioe.getMessage()); } strippedDownScriptName = getFileFromCanonicalPath(scriptFileAbsPath); } } String defaultLogFileName = (strippedDownScriptName == null ? "pig_" : strippedDownScriptName) + new Date().getTime() + ".log"; File logFile; if (logFileName != null) { logFile = new File(logFileName); // Check if the file name is a directory // append the default file name to the file if (logFile.isDirectory()) { if (logFile.canWrite()) { try { logFileName = logFile.getCanonicalPath() + File.separator + defaultLogFileName; } catch (IOException ioe) { throw new AssertionError( "Could not compute canonical path to the log file " + ioe.getMessage()); } return logFileName; } else { throw new AssertionError( "Need write permission in the directory: " + logFileName + " to create log file."); } } else { // we have a relative path or an absolute path to the log file // check if we can write to the directory where this file is/will be stored if (logFile.exists()) { if (logFile.canWrite()) { try { logFileName = new File(logFileName).getCanonicalPath(); } catch (IOException ioe) { throw new AssertionError( "Could not compute canonical path to the log file " + ioe.getMessage()); } return logFileName; } else { // do not have write permissions for the log file // bail out with an error message throw new AssertionError( "Cannot write to file: " + logFileName + ". Need write permission."); } } else { logFile = logFile.getParentFile(); if (logFile != null) { // if the directory is writable we are good to go if (logFile.canWrite()) { try { logFileName = new File(logFileName).getCanonicalPath(); } catch (IOException ioe) { throw new AssertionError( "Could not compute canonical path to the log file " + ioe.getMessage()); } return logFileName; } else { throw new AssertionError( "Need write permission in the directory: " + logFile + " to create log file."); } } // end if logFile != null else is the default in fall through } // end else part of logFile.exists() } // end else part of logFile.isDirectory() } // end if logFileName != null // file name is null or its in the current working directory // revert to the current working directory String currDir = System.getProperty("user.dir"); logFile = new File(currDir); logFileName = currDir + File.separator + (logFileName == null ? defaultLogFileName : logFileName); if (logFile.canWrite()) { return logFileName; } throw new RuntimeException("Cannot write to log file: " + logFileName); }
public static void testSetPackageVersion() throws Exception { File tmp = new File("tmp-ws"); if (tmp.exists()) IO.deleteWithException(tmp); tmp.mkdir(); assertTrue(tmp.isDirectory()); try { IO.copy(new File("test/ws"), tmp); Workspace ws = Workspace.getWorkspace(tmp); Project project = ws.getProject("p5"); project.setTrace(true); Version newVersion = new Version(2, 0, 0); // Package with no package info project.setPackageInfo("pkg1", newVersion); Version version = project.getPackageInfo("pkg1"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg1", true, false); // Package with package-info.java containing @Version("1.0.0") project.setPackageInfo("pkg2", newVersion); version = project.getPackageInfo("pkg2"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg2", false, true); // Package with package-info.java containing @aQute.bnd.annotations.Version("1.0.0") project.setPackageInfo("pkg3", newVersion); version = project.getPackageInfo("pkg3"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg3", false, true); // Package with package-info.java containing @aQute.bnd.annotations.Version(value="1.0.0") project.setPackageInfo("pkg4", newVersion); version = project.getPackageInfo("pkg4"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg4", false, true); // Package with package-info.java containing version + packageinfo project.setPackageInfo("pkg5", newVersion); version = project.getPackageInfo("pkg5"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg5", true, true); // Package with package-info.java NOT containing version + packageinfo project.setPackageInfo("pkg6", newVersion); version = project.getPackageInfo("pkg6"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg6", true, true); // Package with package-info.java NOT containing version project.setPackageInfo("pkg7", newVersion); version = project.getPackageInfo("pkg7"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg7", true, true); newVersion = new Version(2, 2, 0); // Update packageinfo file project.setPackageInfo("pkg1", newVersion); version = project.getPackageInfo("pkg1"); assertEquals(newVersion, version); checkPackageInfoFiles(project, "pkg1", true, false); } finally { IO.deleteWithException(tmp); } }
// where void findFiles(File dir, Set<File> files) { for (File f : dir.listFiles()) { if (f.isDirectory()) findFiles(f, files); else files.add(f); } }
private void mapAndTocForFile(File f, File path, String underscore) { // we get the single name of the file and the urlname int under_index2 = f.getName().indexOf("_"); int point_index2 = f.getName().indexOf("."); String named = f.getName().substring(under_index2 + 1, point_index2); String tmp = path.getAbsolutePath() + "Main_pages/fr/"; String url_name = f.getPath().replace("\\", "/").substring(tmp.length()); String targetName = url_name.substring(0, url_name.lastIndexOf(".html")); // now we will add into the map and the toc print.println("<mapID target=\"" + targetName + "\" url=\"pages/" + url_name + "\"/>"); File dir_associated = new File(f.getParent(), named); if ((dir_associated.exists() && dir_associated.isDirectory()) || named.equals("objects")) { print2.println( "<tocitem text=\"" + getTitle(f) + "\" target=\"" + targetName + "\" image=\"tamicon\">"); if (dir_associated.exists()) { // Apres on fait pareil pour tous les sous fichiers File[] sub_files = dir_associated.listFiles(); for (int i = 0; i < sub_files.length; i++) { if (!sub_files[i].getName().equals("CVS") && sub_files[i].isFile()) { if (sub_files[i].getName().endsWith(".html")) mapAndTocForFile(sub_files[i], path, underscore); else { try { copyFile( sub_files[i], new File(path, "pages/" + named + "/" + sub_files[i].getName())); } catch (IOException e) { LOG.error("Error while copying normal files in help " + e); } } } } } if (named.equals("objects")) { // Specialement pour les objets on les rajoute tous File objects_dir = new File( Configuration.instance() .getTangaraPath() .getParentFile() .getAbsolutePath() .replace("\\", "/") + "/objects/"); File[] listfiles = objects_dir.listFiles(); Vector<String> list_names = new Vector<String>(); HashMap<String, String> map = new HashMap<String, String>(); for (int i = 0; i < listfiles.length; i++) { try { if (listfiles[i].getName().endsWith(".jar")) { int point_index = listfiles[i].getName().lastIndexOf("."); String name = listfiles[i].getName().substring(0, point_index); // Copy the pages in the right directory File object_dir = new File(path, "pages/" + name); object_dir.mkdir(); File object_ressource = new File( Configuration.instance() .getTangaraPath() .getParentFile() .getAbsolutePath() .replace("\\", "/") + "/objects/resources/" + name + "/Help"); if (object_ressource.exists()) { File[] list_html_object = object_ressource.listFiles(); for (int e = 0; e < list_html_object.length; e++) { if (list_html_object[e].getName().endsWith(".html")) { int under_index = list_html_object[e].getName().lastIndexOf("_"); if (underscore.equals("") && under_index == -1) copyFile( list_html_object[e], new File(path, "pages/" + name + "/" + list_html_object[e].getName())); else if (!underscore.equals("")) { if (list_html_object[e].getName().contains(underscore)) copyFile( list_html_object[e], new File(path, "pages/" + name + "/" + list_html_object[e].getName())); } } else copyFile( list_html_object[e], new File(path, "pages/" + name + "/" + list_html_object[e].getName())); } // Gets the name of the object in the selected language String name_lang = null; if (underscore.equals("")) name_lang = name; else { name_lang = getLangName(listfiles[i]); } if (name_lang != null) { list_names.add(name_lang); map.put(name_lang, name); // Add to the map file print.println( "<mapID target=\"" + name + "\" url=\"pages/" + name + "/index" + underscore + ".html\" />"); } } } } catch (Exception e2) { LOG.error("Error2 getHelp " + e2); } } // Add to the tam file Collections.sort(list_names); for (String s : list_names) { print2.println( "<tocitem text=\"" + s + "\" target=\"" + map.get(s) + "\" image=\"fileicon\" />"); } } print2.println("</tocitem>"); } else { // pas de sous fichiers print2.println( "<tocitem text=\"" + getTitle(f) + "\" target=\"" + targetName + "\" image=\"fileicon\"/>"); } File parent = new File(path, "pages/" + url_name.substring(0, url_name.lastIndexOf(named) - 3)); if (!parent.exists()) parent.mkdirs(); File in_pages = new File(path, "pages/" + url_name); try { in_pages.createNewFile(); copyFile(f, in_pages); } catch (IOException e3) { LOG.error("Error 3 getHelp " + e3 + " " + f.getName()); } }