Example usage for java.io File separatorChar

List of usage examples for java.io File separatorChar

Introduction

In this page you can find the example usage for java.io File separatorChar.

Prototype

char separatorChar

To view the source code for java.io File separatorChar.

Click Source Link

Document

The system-dependent default name-separator character.

Usage

From source file:com.opensymphony.webwork.util.classloader.stores.FileResourceStore.java

private File getFile(final String pResourceName) {
    final String fileName = pResourceName.replace('.', File.separatorChar) + ".class";
    return new File(root, fileName);
}

From source file:de.ailis.wlandsuite.UnpackGame.java

/**
 * @see de.ailis.wlandsuite.cli.UnpackProg#unpack(java.io.InputStream,
 *      java.io.File)// w w  w  .j  a  v a2 s  .  c  o m
 */

@Override
public void unpack(InputStream input, File output) throws IOException {
    int mapNo, listNo;
    Game game;
    File file;
    FileOutputStream outputStream;

    // Parse the game file
    game = Game.read(input);

    // Write all maps as XML to disk
    mapNo = 0;
    for (GameMap map : game.getMaps()) {
        file = new File(
                String.format("%s%cmap%02d.xml", new Object[] { output.getPath(), File.separatorChar, mapNo }));

        outputStream = new FileOutputStream(file);
        try {
            log.info("Writing map " + mapNo);
            map.writeXml(outputStream);
        } finally {
            outputStream.close();
        }

        // Increase map counter
        mapNo++;
    }

    // Write the save game
    file = new File(String.format("%s%csavegame.xml", new Object[] { output.getPath(), File.separatorChar }));
    outputStream = new FileOutputStream(file);
    try {
        log.info("Writing savegame");
        game.getSavegame().writeXml(outputStream);
    } finally {
        outputStream.close();
    }

    // Write all shop lists
    listNo = 0;
    for (ShopItemList list : game.getShopItemLists()) {
        file = new File(String.format("%s%cshopitems%d.xml",
                new Object[] { output.getPath(), File.separatorChar, listNo }));

        outputStream = new FileOutputStream(file);
        try {
            log.info("Writing shop item list " + listNo);
            list.writeXml(outputStream);
        } finally {
            outputStream.close();
        }

        // Increase map counter
        listNo++;
    }
}

From source file:com.msopentech.odatajclient.testservice.utils.FSManager.java

public String getAbsolutePath(final String relativePath, final Accept accept) {
    return File.separatorChar + version.name() + File.separatorChar + relativePath
            + (accept == null ? "" : accept.getExtension());
}

From source file:de.shadowhunt.maven.plugins.packageinfo.PackageInfoPlugin.java

static String path2PackageName(final String path) {
    final String strip = StringUtils.strip(path, File.separator);
    return strip.replace(File.separatorChar, '.');
}

From source file:hudson.lifecycle.WindowsSlaveInstaller.java

public Void call() {
    if (File.separatorChar == '/')
        return null; // not Windows
    if (System.getProperty("hudson.showWindowsServiceInstallLink") == null)
        return null; // only show this when it makes sense, which is when we run from JNLP

    dialog = MainDialog.get();/*from   w  w  w. j  av  a  2 s .  c  o m*/
    if (dialog == null)
        return null; // can't find the main window. Maybe not running with GUI

    // capture the engine
    engine = Engine.current();

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            MainMenu mainMenu = dialog.getMainMenu();
            JMenu m = mainMenu.getFileMenu();
            JMenuItem menu = new JMenuItem(Messages.WindowsInstallerLink_DisplayName(), KeyEvent.VK_W);
            menu.addActionListener(WindowsSlaveInstaller.this);
            m.add(menu);
            mainMenu.commit();
        }
    });

    return null;
}

From source file:es.ehu.si.ixa.qwn.ppv.UKBwrapper.java

public UKBwrapper(String langordict, String outFolder) {
    // temporal files directory
    this.outDir = outFolder;

    // location of the graph jar file, root to the graph directory
    String jarLocation = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
    this.location = jarLocation.substring(0, jarLocation.lastIndexOf(File.separatorChar));

    try {/*ww w.ja va  2  s .  co m*/
        AvailableDicts.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("dicts.txt"));
        AvailableGraphs.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("graphs.txt"));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        System.err.println(
                "PropagationUKB class initialization: error when loading lkb_resources properties (dicts/graphs).\n");
        e.printStackTrace();

    }

    if (AvailableDicts.containsKey(langordict)) {
        String destPath = this.outDir + File.separator + (String) AvailableDicts.get(langordict);

        try {
            InputStream dictToExtract = this.getClass().getClassLoader()
                    .getResourceAsStream("dicts/" + (String) AvailableDicts.get(langordict));
            OutputStream dictDestination = new FileOutputStream(destPath);
            IOUtils.copy(dictToExtract, dictDestination);
            dictToExtract.close();
            dictDestination.close();
        } catch (FileNotFoundException e) {
            System.err.println(
                    "PropagationUKB class initialization: could not extract (create) needed dictionary file\n");
            e.printStackTrace();
        } catch (IOException ioe) {
            System.err
                    .println("PropagationUKB class initialization: could not extract needed dictionary file\n");
            ioe.printStackTrace();
        }

        this.langDict = destPath;
    }
    //if language is not available assume that the argument corresponds to a custom dictionary path.
    else {
        System.err.println("PropagationUKB class: provided language is not available (" + langordict + "), "
                + "qwn-ppv assumes that the argument provide is the path to a custom language dictionary.\n");
        this.langDict = langordict;
    }

}

From source file:mx.itesm.imb.ImbBusController.java

@SuppressWarnings("unchecked")
public static void generateImbBusController(final File rooProject, final File busProject) {
    Writer writer;/*from  w  w w  .  java 2 s  . c o m*/
    File typeReference;
    File controllerFile;
    int basePackageIndex;
    String imbTypePackage;
    String webConfiguration;
    VelocityContext context;
    Collection<String> types;
    String controllerPackage;
    Iterator<File> typesIterator;

    try {
        // Copy imb types
        FileUtils.copyDirectory(new File(rooProject, "/src/main/java/imb"),
                new File(busProject, "/src/main/java/imb"));
        FileUtils.copyFile(new File(rooProject, "/src/main/resources/schema.xsd"),
                new File(busProject, "/src/main/resources/schema.xsd"));

        imbTypePackage = null;
        types = new ArrayList<String>();
        typesIterator = FileUtils.iterateFiles(new File(busProject, "/src/main/java/imb"),
                new String[] { "java" }, true);
        while (typesIterator.hasNext()) {
            typeReference = typesIterator.next();
            if ((!typeReference.getName().equals("ObjectFactory.java"))
                    && (!typeReference.getName().equals("package-info.java"))) {
                if (FileUtils.readFileToString(typeReference).contains("public class")) {
                    types.add(typeReference.getName().replace(".java", ""));
                    if (imbTypePackage == null) {
                        imbTypePackage = typeReference.getPath()
                                .substring(
                                        typeReference.getPath().indexOf("src/main/java")
                                                + "src/main/java".length() + 1,
                                        typeReference.getPath().indexOf(typeReference.getName()) - 1)
                                .replace(File.separatorChar, '.');
                    }
                }
            }
        }

        // Add rest configuration
        FileUtils.copyFile(
                new File(rooProject,
                        "/src/main/resources/META-INF/spring/applicationContext-contentresolver.xml"),
                new File(busProject,
                        "/src/main/resources/META-INF/spring/applicationContext-contentresolver.xml"));

        context = new VelocityContext();
        context.put("types", types);
        context.put("imbTypePackage", imbTypePackage);

        webConfiguration = FileUtils
                .readFileToString(new File(busProject, "src/main/webapp/WEB-INF/spring/webmvc-config.xml"));
        basePackageIndex = webConfiguration.indexOf("base-package=\"") + "base-package=\"".length();
        controllerPackage = webConfiguration.substring(basePackageIndex,
                webConfiguration.indexOf('"', basePackageIndex)) + ".web";
        context.put("controllerPackage", controllerPackage);
        context.put("typePackage", controllerPackage.replace(".web", ".domain"));
        controllerFile = new File(busProject,
                "/src/main/java/" + controllerPackage.replace('.', '/') + "/ImbBusController.java");
        writer = new FileWriter(controllerFile);
        ImbBusController.controllerTemplate.merge(context, writer);
        writer.close();
    } catch (Exception e) {
        System.out.println("Error while configuring IMB Bus: " + e.getMessage());
    }
}

From source file:cc.creativecomputing.io.CCIOUtil.java

/**
 * Gets the name of the given file without an extension. You can pass the file as a a String or a
 * java file./*from w ww .  j  a v  a2s. c o m*/
 * @param theFile
 * @return
 */
public static String fileName(final String theFile) {
    final int myIndex = theFile.lastIndexOf('.');
    final int mySeperator = theFile.lastIndexOf(File.separatorChar);
    return theFile.substring(CCMath.max(0, mySeperator), myIndex);
}

From source file:de.ailis.wlandsuite.PackCpa.java

/**
 * @see de.ailis.wlandsuite.cli.PackProg#pack(java.io.File,
 *      java.io.OutputStream)//from   ww  w.j ava 2 s. c  o  m
 */

@Override
protected void pack(File directory, OutputStream output) throws IOException {
    Cpa cpa;
    Pic baseFrame;
    Pic pic;
    List<CpaFrame> frames;
    int frameNo;
    File frameFile;
    BufferedReader reader;
    String line;
    List<Integer> delays;
    int delay;
    File file;

    // Read the base frame
    file = new File(directory.getPath() + File.separatorChar + "000.png");
    if (!file.exists()) {
        log.error("Base frame PNG '" + file.getPath() + "' not found");
    }
    baseFrame = new Pic(ImageIO.read(file));

    // Read the animation delays
    delays = new ArrayList<Integer>();
    file = new File(directory.getPath() + File.separatorChar + "delays.txt");
    if (file.exists()) {
        reader = new BufferedReader(new FileReader(file));
        try {
            while ((line = reader.readLine()) != null) {
                line = line.trim();
                if (line.length() == 0 || line.startsWith("#")) {
                    continue;
                }
                delays.add(Integer.valueOf(line));
            }
        } finally {
            reader.close();
        }
    } else {
        log.warn("Delays file '" + file.getPath() + "' not found");
    }

    // Read the animation frames
    frames = new ArrayList<CpaFrame>();
    frameNo = 1;
    while (true) {
        frameFile = new File(String.format("%s%c%03d.png",
                new Object[] { directory.getPath(), File.separatorChar, frameNo }));
        if (!frameFile.exists()) {
            break;
        }
        pic = new Pic(ImageIO.read(frameFile));
        if (frameNo > delays.size()) {
            log.warn("No delay found for frame " + frameNo + ". Using default delay 2");
            delay = 2;
        } else {
            delay = delays.get(frameNo - 1);
        }
        frames.add(new CpaFrame(delay, pic));
        frameNo++;
    }
    if (frameNo != 16) {
        log.warn("Wasteland needs 15 animation frames. But " + (frameNo - 1)
                + " frames were found. This may cause trouble.");
    }

    cpa = new Cpa(baseFrame, frames);
    cpa.write(output);
}

From source file:net.ion.radon.cload.stores.FileResourceStore.java

private File getFile(final String pResourceName) {
    final String fileName = pResourceName.replace('/', File.separatorChar);
    return new File(root, fileName);
}