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:de.ailis.wlandsuite.ExtractMaps.java

/**
 * @see de.ailis.wlandsuite.cli.ExtractProg#extract(java.io.File,
 *      java.io.File)// ww w .ja v a2  s  .  c  o  m
 */

@Override
public void extract(File input, File output) throws IOException {
    Game game1, game2;
    Htds htds1, htds2;
    Sprites sprites;
    InputStream stream;

    // Read game 1
    log.info("Reading game1");
    stream = new FileInputStream(new File(input.getAbsolutePath() + File.separatorChar + "game1"));
    try {
        game1 = Game.read(stream);
    } finally {
        stream.close();
    }

    // Read game 2
    log.info("Reading game2");
    stream = new FileInputStream(new File(input.getAbsolutePath() + File.separatorChar + "game2"));
    try {
        game2 = Game.read(stream);
    } finally {
        stream.close();
    }

    // Read tileset 1
    log.info("Reading allhtds1");
    stream = new FileInputStream(new File(input.getAbsolutePath() + File.separatorChar + "allhtds1"));
    try {
        htds1 = Htds.read(stream);
    } finally {
        stream.close();
    }

    // Read tileset 2
    log.info("Reading allhtds2");
    stream = new FileInputStream(new File(input.getAbsolutePath() + File.separatorChar + "allhtds2"));
    try {
        htds2 = Htds.read(stream);
    } finally {
        stream.close();
    }

    // Read sprites
    stream = new FileInputStream(new File(input.getAbsolutePath() + File.separatorChar + "ic0_9.wlf"));
    try {
        log.info("Reading sprites");
        sprites = Sprites.read(stream);
    } finally {
        stream.close();
    }

    // Iterate over both game files
    int fileNo = 100;
    for (Game game : new Game[] { game1, game2 }) {
        // Iterate over all maps of the current game file
        for (GameMap gameMap : game.getMaps()) {
            log.info("Writing map " + fileNo);
            int tilesetId = gameMap.getInfo().getTileset();
            int size = gameMap.getMapSize();
            EgaImage image = new EgaImage(size * 16, size * 16);
            Graphics2D graphics = image.createGraphics();
            List<Pic> tiles;

            if (tilesetId < 4) {
                tiles = htds1.getTilesets().get(tilesetId).getTiles();
            } else {
                tiles = htds2.getTilesets().get(tilesetId - 4).getTiles();
            }
            TileMap map = gameMap.getTileMap();

            for (int y = 0; y < size; y++) {
                for (int x = 0; x < size; x++) {
                    int tile = map.getTile(x, y);

                    if (tile >= 10) {
                        graphics.drawImage(tiles.get(tile - 10), x * 16, y * 16, null);
                    } else {
                        graphics.drawImage(sprites.getSprites().get(tile), x * 16, y * 16, null);
                    }
                }
            }

            // Write the image to disk
            File file = new File(
                    String.format("%s%c%03d.png", new Object[] { output, File.separatorChar, fileNo }));
            ImageIO.write(image, "PNG", file);

            fileNo++;
        }
        fileNo = 200;
    }
}

From source file:com.ibm.replication.iidr.utils.Bookmarks.java

/**
 * Load the bookmarks from the properties file
 *//*w w w  .j a v  a 2  s . c o  m*/
private void loadBookmarks(String bookmarksFileName)
        throws ConfigurationException, FileNotFoundException, IOException {
    String bookmarkDirFullName = System.getProperty("user.dir") + File.separatorChar + "conf" + File.separator
            + "bookmarks";
    String bookmarkFullFileName = bookmarkDirFullName + File.separator + bookmarksFileName;
    File bookmarkFile = new File(bookmarkFullFileName);
    // Create the bookmark file if it doesn't exist
    if (!bookmarkFile.exists()) {
        new File(bookmarkDirFullName).mkdirs();
        new FileOutputStream(bookmarkFullFileName, true).close();
    }
    // Get bookmarks
    bookmarks = new PropertiesConfiguration(bookmarkFile);
    Iterator<String> bookmarkKeys = bookmarks.getKeys();
    while (bookmarkKeys.hasNext()) {
        String bookmarkKey = bookmarkKeys.next();
        logger.debug("Bookmark: " + bookmarkKey + " = " + (String) bookmarks.getProperty(bookmarkKey));
    }
    // Make sure that any updates to the bookmarks is automatically saved
    bookmarks.setAutoSave(true);
}

From source file:org.openmeetings.app.documents.GenerateImage.java

public HashMap<String, HashMap<String, String>> convertImage(String current_dir, String fileName,
        String fileExt, String roomName, String fileNameShort, boolean fullProcessing) throws Exception {

    HashMap<String, HashMap<String, String>> returnMap = new HashMap<String, HashMap<String, String>>();

    String working_imgdir = current_dir + OpenmeetingsVariables.UPLOAD_DIR + File.separatorChar + roomName
            + File.separatorChar;
    String working_pptdir = current_dir + OpenmeetingsVariables.UPLOAD_TEMP_DIR + File.separatorChar + roomName
            + File.separatorChar;

    String fileFullPath = working_pptdir + fileName + fileExt;

    File f = new File(working_imgdir + fileName + fileExt);
    if (f.exists()) {
        int recursiveNumber = 0;
        String tempd = fileName + "_" + recursiveNumber;
        while (f.exists()) {
            recursiveNumber++;/*from  w w w .j  ava 2s .c  o  m*/
            tempd = fileName + "_" + recursiveNumber;
            f = new File(working_imgdir + tempd + fileExt);
        }
        fileName = tempd;
    }

    String destinationFile = working_imgdir + fileName;

    log.debug("##### convertImage destinationFile: " + destinationFile);

    HashMap<String, String> processJPG = this.convertSingleJpg(fileFullPath, destinationFile);
    HashMap<String, String> processThumb = generateThumbs.generateThumb("_thumb_", current_dir, destinationFile,
            50);

    returnMap.put("processJPG", processJPG);
    returnMap.put("processThumb", processThumb);

    // Delete old one
    File fToDelete = new File(fileFullPath);
    fToDelete.delete();

    return returnMap;
}

From source file:eionet.gdem.dcm.conf.DcmProperties.java

public void setLdapParams(String url, String context, String userDir, String attrUid) throws DCMException {

    String filePath = Properties.appHome + File.separatorChar + "eionetdir.properties";

    try {//from   w ww  .j a v a2s  . c o m

        BufferedReader reader = new BufferedReader(new FileReader(filePath));
        String line = null;
        StringBuffer st = new StringBuffer();

        while ((line = reader.readLine()) != null) {
            // process the line
            line = findSetProp(line, "ldap.url", url);
            line = findSetProp(line, "ldap.context", context);
            line = findSetProp(line, "ldap.user.dir", userDir);
            line = findSetProp(line, "ldap.attr.uid", attrUid);
            st.append(line);
            st.append("\n");
        }

        BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
        out.write(st.toString());
        out.close();
    } catch (IOException e) {
        LOGGER.error("Saving ldap parameters failed!", e);
        e.printStackTrace();
        throw new DCMException(BusinessConstants.EXCEPTION_PARAM_LDAP_FAILED);
    }
}

From source file:com.stratio.decision.unit.engine.action.CassandraServer.java

/**
 * Set embedded cassandra up and spawn it in a new thread.
 * // w w w .  j ava  2s . c om
 * @throws TTransportException
 * @throws IOException
 * @throws InterruptedException
 */
public void start() throws TTransportException, IOException, InterruptedException, ConfigurationException {

    File dir = Files.createTempDir();
    String dirPath = dir.getAbsolutePath();
    System.out.println("Storing Cassandra files in " + dirPath);

    URL url = Resources.getResource("cassandra.yaml");
    String yaml = Resources.toString(url, Charsets.UTF_8);
    yaml = yaml.replaceAll("REPLACEDIR", dirPath);
    String yamlPath = dirPath + File.separatorChar + "cassandra.yaml";
    org.apache.commons.io.FileUtils.writeStringToFile(new File(yamlPath), yaml);

    // make a tmp dir and copy cassandra.yaml and log4j.properties to it
    copy("/log4j.properties", dir.getAbsolutePath());
    System.setProperty("cassandra.config", "file:" + dirPath + yamlFilePath);
    System.setProperty("log4j.configuration", "file:" + dirPath + "/log4j.properties");
    System.setProperty("cassandra-foreground", "true");

    cleanupAndLeaveDirs();

    try {
        executor.execute(new CassandraRunner());
    } catch (RejectedExecutionException e) {
        log.error("RejectError", e);
        return;
    }

    try {
        TimeUnit.SECONDS.sleep(WAIT_SECONDS);
    } catch (InterruptedException e) {
        log.error("InterrputedError", e);
        throw new AssertionError(e);
    }
}

From source file:jfs.sync.encfs.JFSEncfsFile.java

/**
 * Creates a new external file for a certain path using a specific file producer.
 * /*from  w w  w .  j  a v a  2 s  .c om*/
 * @param access
 *            The server access object to use.
 * @param fileProducer
 *            The assigned file producer.
 * @param path
 *            The path to create the external file for.
 */
public JFSEncfsFile(EncFSVolume access, JFSFileProducer fileProducer, String path, boolean isDirectory) {
    super(fileProducer, path);
    path = path.replace(File.separatorChar, '/');

    this.access = access;

    try {
        String[] pathAndName = AbstractJFSFileProducerFactory.getPathAndName(path, "/");
        info = new FileInfo();
        info.setPath(pathAndName[0]);
        info.setName(pathAndName[1]);
        info.setDirectory(isDirectory);
        try {
            file = access.getFile(path.length() == 0 ? "/" : path);
            info.setCanRead(file.isReadable());
            info.setCanWrite(file.isWritable());
            info.setPath(file.getParentPath());
            info.setName(path.length() == 0 ? "" : file.getName());
            info.setDirectory(file.isDirectory());
            info.setExists(file.isReadable());
            info.setModificationDate(file.getLastModified());
            info.setSize(file.getLength());
        } catch (IllegalArgumentException iae) {
            log.warn("()", iae);
            info.setExists(false);
        } // try/catch

    } catch (Exception e) {
        log.error("()", e);
    } // try/catch

    if (log.isInfoEnabled()) {
        log.info("() " + (info.isDirectory() ? "d" : "-") + (info.isExists() ? "e" : "-") + " | "
                + info.getPath() + "/" + info.getName());
    } // if
}

From source file:com.consol.citrus.admin.executor.ClasspathTestExecutor.java

/**
 * {@inheritDoc}//from  w w  w. j a  v a 2s .com
 */
public List<TestCaseType> getTests() {
    List<TestCaseType> tests = new ArrayList<TestCaseType>();

    List<String> testFiles = findTestsInClasspath(System.getProperty(BASE_PACKAGE, "com.consol.citrus"));

    for (String file : testFiles) {
        String testName = file.substring(file.lastIndexOf(".") + 1);
        String testPackageName = file.substring(0, file.length() - testName.length() - 1)
                .replace(File.separatorChar, '.');

        TestCaseType testCase = new TestCaseType();
        testCase.setName(testName);
        testCase.setPackageName(testPackageName);

        tests.add(testCase);
    }

    return tests;
}

From source file:gov.nih.nci.sdk.example.generator.util.GeneratorUtil.java

public static String getJaxbPojoPath(ScriptContext _scriptContext) {
    String s = getGeneratedPath(_scriptContext);
    String jaxbPojoPath = s + File.separator
            + EcoreUtil.determinePackageName(_scriptContext.getFocusDomain()).replace('.', File.separatorChar)
            + File.separator + Generator.JAXBPOJO_PACKAGE_NAME;

    return jaxbPojoPath;
}

From source file:com.dx.ss.plugins.ptree.main.MavenShellCallback.java

public File getDirectory(String targetProject, String targetPackage) {
    // targetProject is interpreted as a directory that must exist
    ///*from w ww . ja va  2  s  .  c om*/
    // targetPackage is interpreted as a sub directory, but in package
    // format (with dots instead of slashes). The sub directory will be
    // created
    // if it does not already exist
    if (!"MAVEN".equals(targetProject)) {
        return super.getDirectory(targetProject, targetPackage);
    }

    // targetProject is the output directory from the MyBatis generator
    // Mojo. It will be created if necessary
    //
    // targetPackage is interpreted as a sub directory, but in package
    // format (with dots instead of slashes).  The sub directory will be created
    // if it does not already exist

    File project = pTreeGeneratorMojo.getOutputDirectory();
    if (!project.exists()) {
        project.mkdirs();
    }

    StringBuilder sb = new StringBuilder();
    if (!StringUtils.isBlank(targetPackage)) {
        StringTokenizer st = new StringTokenizer(targetPackage, "."); //$NON-NLS-1$
        while (st.hasMoreTokens()) {
            sb.append(st.nextToken());
            sb.append(File.separatorChar);
        }
    }

    File directory = new File(project, sb.toString());
    if (!directory.isDirectory()) {
        boolean rc = directory.mkdirs();
        if (!rc)
            return null;
    }

    return directory;
}

From source file:net.sourceforge.mavenhippo.FileManager.java

public File getPackage(String[] packagePath) throws FileManagerException {
    String foldersPath = StringUtils.join(packagePath, File.separatorChar);
    File result = new File(sourceRoot + File.separator + foldersPath);
    if (result.exists()) {
        if (!result.isDirectory()) {
            throw new FileManagerException(
                    "there is already a file at \"" + result.getAbsolutePath() + "\" but it is not a folder.");
        }/*from  ww  w.ja  v a  2 s . c om*/
    } else {
        if (!result.mkdirs()) {
            throw new FileManagerException("attemped to create folders failed.");
        } else {
            log.info("the following folder(s) " + foldersPath + " were created.");
        }
    }
    return result;
}