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:org.openxdata.server.report.birt.ReportManager.java

/**
 * Get the configuration object for the BIRT report engine.
 *
 * @return returns the configured report object of BIRT report engine.
 *///from  www.  ja  va 2 s.c  o m
public synchronized EngineConfig getEngineConfig() {
    if (engineConfig == null) {
        String birtHome = System.getProperty("user.home") + File.separatorChar + "birt-runtime-2_5_0"
                + File.separatorChar + "ReportEngine";
        birtHome = settingService.getSetting("birtHome", birtHome);
        log.info("Creating BIRT engine config with BIRT_HOME = " + birtHome);
        engineConfig = new EngineConfig();
        engineConfig.setEngineHome(birtHome);
        engineConfig.setLogConfig(BirtConstants.LOGGING_DIR, BirtConstants.LOGGING_LEVEL);
    }

    return engineConfig;
}

From source file:com.pieframework.runtime.utils.ArtifactManager.java

private void copy(String download, String filter, String localPath, String virtualPath) {

    /*System.out.println("download:"+download+
             "\nfilter:"+filter+/*from   ww w. j  a va 2 s .  c o  m*/
             "\nlocalPath:"+localPath+
             "\nvirtualPath:"+virtualPath);
    */
    boolean match = true;
    if (!StringUtils.empty(filter)) {
        match = FilenameUtils.wildcardMatch(FilenameUtils.separatorsToSystem(download), filter);
    }

    if (match) {

        File destinationVirtualFile = new File(FilenameUtils.separatorsToSystem(virtualPath));
        File destination = new File(localPath + destinationVirtualFile.getParent());
        destination.mkdirs();

        if (destination.exists()) {
            File downloadFile = new File(download);
            try {
                FileUtils.copyFileToDirectory(downloadFile, destination);
                File copiedFile = new File(
                        destination.getPath() + File.separatorChar + destinationVirtualFile.getName());
                if (copiedFile.exists()) {
                    System.out.println(
                            "file copied:" + copiedFile + " crc:" + FileUtils.checksumCRC32(copiedFile));
                } else {
                    //TODO error
                }

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
            //TODO error
        }

    }
}

From source file:com.nridge.core.base.std.FilUtl.java

/**
 * Combines the current working directory/folder with a relative path file
 * name.//from  w w  w.  j a v  a 2  s. co  m
 * <p>
 * Invoking <code>getWDPathFileName("resources\\somefile.txt")</code>
 * would produce: <i>"C:\\current\\workdir\\resources\\somefile.txt"</i>
 * </p>
 * @param aRelativeName A relative path file name.
 * @return A concatenated string: WD + RN
 */
static public String getWDPathFileName(String aRelativeName) {
    if (StringUtils.isNotEmpty(aRelativeName)) {
        int strLength = aRelativeName.length();
        if (aRelativeName.charAt(strLength - 1) == File.separatorChar)
            return getWorkingDirectory() + aRelativeName;
        else
            return String.format("%s%c%s", getWorkingDirectory(), File.separatorChar, aRelativeName);
    } else
        return getWorkingDirectory();
}

From source file:com.sqli.liferay.imex.util.xml.ZipUtils.java

private void zipEntries(ZipOutputStream out, File file, File inputDir) throws IOException {
    String name;/*w ww  .ja v  a  2s  .  c  o m*/
    if (file.equals(inputDir)) {
        name = "";
    } else {
        name = file.getPath().substring(inputDir.getPath().length() + 1);
    }
    if (File.separatorChar == '\\') {
        name = name.replace("\\", "/");
    }

    log.debug("Adding: " + name);

    if (file.isDirectory()) {
        for (File child : file.listFiles()) {
            zipEntries(out, child, inputDir);
        }
    } else {
        ZipEntry entry = new ZipEntry(name);
        out.putNextEntry(entry);
        IOUtils.copy(FileUtils.openInputStream(file), out);
    }
}

From source file:com.qualogy.qafe.business.resource.java.spring.SpringContext.java

public String resolveXMLConfigFile(String root, String xmlConfigFile) {
    URI uri = null;//from w  w  w . ja  v a  2  s. c  om

    if (!StringUtils.isEmpty(root) && !root.endsWith("/") && !root.endsWith("\\")) {
        root += File.separator;
    }

    String path = ((root != null) ? root : "") + ((xmlConfigFile != null) ? xmlConfigFile : "");

    if (File.separatorChar == '\\') {
        path = path.replace('\\', '/');
    }

    if (path.startsWith(FileLocation.SCHEME_HTTP + FileLocation.COMMON_SCHEME_DELIM)) {
        try {
            URL url = new URL(path);
            uri = url.toURI();
        } catch (MalformedURLException e) {
            throw new BindException(e);
        } catch (URISyntaxException e) {
            throw new BindException(e);
        }
    } else if (path.startsWith(FileLocation.SCHEME_FILE)) {
        try {
            uri = new URI(path);
        } catch (URISyntaxException e) {
            throw new BindException(e);
        }
    } else {
        if (!StringUtils.isEmpty(root) && !root.startsWith("/") && !root.startsWith("\\")) {
            root = File.separator + root;
        }
        File file = StringUtils.isEmpty(root) ? new File(((xmlConfigFile != null) ? xmlConfigFile : ""))
                : new File(root, ((xmlConfigFile != null) ? xmlConfigFile : ""));
        uri = file.toURI();
        return "file:" + uri.getPath();
    }
    return uri.getPath();
}

From source file:gov.nih.nci.cagrid.gts.service.CertificateRevocationLists.java

public synchronized void reload(String locations) {
    if (locations == null) {
        return;// w  w w.  j av  a 2  s  .co m
    }

    StringTokenizer tokens = new StringTokenizer(locations, ",");
    File crlFile = null;

    Map newCrlFileMap = new HashMap();
    Map newCrlIssuerDNMap = new HashMap();

    while (tokens.hasMoreTokens()) {
        crlFile = new File(tokens.nextToken().toString().trim());

        if (!crlFile.canRead()) {
            logger.debug("Cannot read: " + crlFile.getAbsolutePath());
            continue;
        }

        if (crlFile.isDirectory()) {
            String[] crlFiles = crlFile.list(getCrlFilter());
            if (crlFiles == null) {
                logger.debug("Cannot load CRLs from " + crlFile.getAbsolutePath() + " directory.");
            } else {
                logger.debug("Loading CRLs from " + crlFile.getAbsolutePath() + " directory.");
                for (int i = 0; i < crlFiles.length; i++) {
                    String crlFilename = crlFile.getPath() + File.separatorChar + crlFiles[i];
                    File crlFilenameFile = new File(crlFilename);
                    if (crlFilenameFile.canRead()) {
                        loadCrl(crlFilename, crlFilenameFile.lastModified(), newCrlFileMap, newCrlIssuerDNMap);
                    } else {
                        logger.debug("Cannot read: " + crlFilenameFile.getAbsolutePath());
                    }
                }
            }
        } else {
            loadCrl(crlFile.getAbsolutePath(), crlFile.lastModified(), newCrlFileMap, newCrlIssuerDNMap);
        }
    }

    this.crlFileMap = newCrlFileMap;
    this.crlIssuerDNMap = newCrlIssuerDNMap;
}

From source file:Repackage.java

public void repackageFile(String name) throws IOException {
    if (name.endsWith(".java"))
        repackageJavaFile(name);//from  w w w.j av  a2s .  c  om
    else if (name.endsWith(".xsdconfig") || name.endsWith(".xml") || name.endsWith(".g"))
        repackageNonJavaFile(name);
    else if (name.startsWith("bin" + File.separatorChar))
        repackageNonJavaFile(name);
    else
        moveAlongWithJavaFiles(name);
}

From source file:com.flipkart.poseidon.serviceclients.generator.Generator.java

private static void ensurePaths() {
    File javaFolder = new File(modulePath + DESTINATION_JAVA_FOLDER.replace('.', File.separatorChar));
    if (!javaFolder.exists() && !javaFolder.mkdirs()) {
        logger.warn("Couldn't create destination java folder");
    }/* ww w  . ja va  2  s.  com*/
}

From source file:FileLocator.java

/**
 * Search for a file using the properties: user.dir, user.home, java.home
 * Returns absolute path name or null./*from   w w w .java 2s  .c  om*/
 */
private static synchronized String locateByProperty(String findFile) {
    String fullPathName = null;
    String dir = null;
    File f = null;

    if (findFile == null)
        return null;

    try {
        // System.err.println("Searching in user.dir for: " + findFile);

        dir = System.getProperty("user.dir");
        if (dir != null) {
            fullPathName = dir + File.separatorChar + findFile;
            f = new File(fullPathName);
        }
        if (f != null && f.exists()) {
            // System.err.println("Found in user.dir");
            return fullPathName;
        }

        dir = System.getProperty("user.home");
        if (dir != null) {
            fullPathName = dir + File.separatorChar + findFile;
            f = new File(fullPathName);
        }
        if (f != null && f.exists()) {
            // System.err.println("Found in user.home");
            return fullPathName;
        }

        dir = System.getProperty("java.home");
        if (dir != null) {
            fullPathName = dir + File.separatorChar + findFile;
            f = new File(fullPathName);
        }
        if (f != null && f.exists()) {
            // System.err.println("Found in java.home");
            return fullPathName;
        }
    } catch (Exception e) {
        return null;
    }
    return null;
}

From source file:com.dmsl.anyplace.tasks.FetchFloorPlanTask.java

@Override
protected String doInBackground(Void... params) {
    OutputStream output = null;/*from   ww  w. jav  a 2  s  .  co m*/
    InputStream is = null;
    File tempFile = null;
    try {

        // check sdcard state
        if (!AndroidUtils.checkExternalStorageState()) {
            // we cannot download the floor plan on the sdcard
            return "Error: It seems that we cannot write on your sdcard!";
        }

        File sdcard_root = ctx.getExternalFilesDir(null);
        if (sdcard_root == null) {
            return "Error: It seems we cannot save the floorplan on sdcard!";
        }
        File root = new File(sdcard_root,
                "floor_plans" + File.separatorChar + buid + File.separatorChar + floor_number);
        root.mkdirs();
        File dest_path = new File(root, "tiles_archive.zip");

        File okfile = new File(root, "ok.txt");

        // check if the file already exists and if yes return
        // immediately
        if (dest_path.exists() && dest_path.canRead() && dest_path.isFile() && okfile.exists()) {
            floor_plan_file = dest_path;
            success = true;
            return "Successfully read floor plan from cache!";
        }

        runPreExecuteOnUI();
        okfile.delete();

        // prepare the json object request
        JSONObject j = new JSONObject();

        j.put("username", "username");
        j.put("password", "pass");

        is = NetworkUtils.downloadHttpClientJsonPostStream(
                AnyplaceAPI.getServeFloorTilesZipUrl(buid, floor_number), j.toString());

        tempFile = new File(ctx.getCacheDir(), "FloorPlan" + Integer.toString((int) (Math.random() * 100)));
        if (tempFile.exists())
            throw new Exception("Temp File already in use");

        output = new FileOutputStream(tempFile);

        byte[] buffer = new byte[4096];
        int bytesRead = 0;
        while ((bytesRead = is.read(buffer, 0, buffer.length)) >= 0) {
            output.write(buffer, 0, bytesRead);
        }

        output.close();

        // Critical Block - Added for safety
        synchronized (sync) {
            copy(tempFile, dest_path);
            // unzip the tiles_archive
            AndroidUtils.unzip(dest_path.getAbsolutePath());

            FileWriter out = new FileWriter(okfile);
            out.write("ok;version:0;");
            out.close();
        }

        floor_plan_file = dest_path;
        waitPreExecute();
        success = true;
        return "Successfully fetched floor plan";

    } catch (ConnectTimeoutException e) {
        return "Cannot connect to Anyplace service!";
    } catch (SocketTimeoutException e) {
        return "Communication with the server is taking too long!";
    } catch (JSONException e) {
        return "JSONException: " + e.getMessage();
    } catch (Exception e) {
        return "Error fetching floor plan. [ " + e.getMessage() + " ]";
    } finally {
        if (is != null)
            try {
                is.close();
            } catch (IOException e) {
            }
        if (output != null)
            try {
                output.close();
            } catch (IOException e) {
            }
        if (tempFile != null) {
            tempFile.delete();
        }

    }

}