Example usage for org.apache.commons.lang SystemUtils JAVA_IO_TMPDIR

List of usage examples for org.apache.commons.lang SystemUtils JAVA_IO_TMPDIR

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils JAVA_IO_TMPDIR.

Prototype

String JAVA_IO_TMPDIR

To view the source code for org.apache.commons.lang SystemUtils JAVA_IO_TMPDIR.

Click Source Link

Document

The java.io.tmpdir System Property.

Usage

From source file:com.flagleader.builder.FlagLeader.java

public static void main(String[] paramArrayOfString) {
    Shell localShell = new Shell(16777216);
    localShell.setLocation(new Point(300, 200));
    localShell.setLayout(new FillLayout());
    Composite localComposite = new Composite(localShell, 0);
    localComposite.setLayout(new FillLayout());
    Label localLabel = new Label(localComposite, 0);
    Image localImage = ImageDescriptor
            .createFromURL(localShell.getClass().getClassLoader().getResource("icons/start.jpg")).createImage();
    localLabel.setImage(localImage);/*from  www  . j a  v a  2s.co  m*/
    localShell.setSize(400, 300);
    localShell.setText("Visual Rules Solution");
    localShell.open();
    Init.a();
    String str = null;
    if (BuilderConfig.getInstance().isLoadDefault())
        str = RuleRepository.DEFAULTEXT;
    if (paramArrayOfString.length > 0)
        str = "";
    for (int i = 0; i < paramArrayOfString.length; i++)
        str = str + paramArrayOfString[i] + " ";
    Logger localLogger = Logger.getLogger("ruleengine");
    Object localObject;
    try {
        new File(SystemUtils.USER_HOME + File.separator + ".visualrules" + File.separator + "logs").mkdirs();
        FileHandler localFileHandler = new FileHandler(SystemUtils.USER_HOME + File.separator + ".visualrules"
                + File.separator + "logs" + File.separator + "logfile%u.%g.txt", 0, 10);
        localFileHandler.setFormatter(new com.flagleader.server.c());
        localFileHandler.setLevel(Level.ALL);
        Logger.getLogger("flagleader").addHandler(localFileHandler);
        localLogger.addHandler(localFileHandler);
    } catch (Exception localException1) {
        if (!b) {
            localObject = new ConsoleHandler();
            ((ConsoleHandler) localObject).setFormatter(new com.flagleader.server.c());
            ((ConsoleHandler) localObject).setLevel(Level.ALL);
            Logger.getLogger("flagleader").addHandler((Handler) localObject);
            localLogger.addHandler((Handler) localObject);
        }
    }
    if (!BuilderManager.checkLicense()) {
        localImage.dispose();
        localShell.dispose();
        return;
    }
    Property.getInstance().setEngineImplement("com.flagleader.engine.impl.SingleRuleEngineFactory");
    FlagLeader localFlagLeader = new FlagLeader();
    Property.getInstance().setUpdateInternateTime(0L);
    localFlagLeader.setBlockOnOpen(true);
    localFlagLeader.builderManager = new BuilderManager(localFlagLeader);
    if ((com.flagleader.manager.d.c.a("needLogin", false)) || (BuilderConfig.getInstance().isFirstLogin()))
        try {
            localObject = localFlagLeader.builderManager.getUserServer();
            if ((localObject == null) || (((String) localObject).length() == 0)
                    || (localFlagLeader.builderManager.getUserType() == 0)
                    || (localFlagLeader.builderManager.getUserid() == 0)) {
                localImage.dispose();
                localShell.dispose();
                return;
            }
        } catch (Exception localException2) {
            MessageDialog.openError(null, "",
                    ResourceTools.getMessage("loginserver.error") + localException2.getLocalizedMessage());
            localImage.dispose();
            localShell.dispose();
            return;
        }
    if ((str != null) && (new File(str).exists()))
        localFlagLeader.builderManager.getRulesManager().a(new File(str));
    localFlagLeader.initWindow();
    if (new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").exists())
        new File(SystemUtils.JAVA_IO_TMPDIR, "engine.jar").delete();
    if (new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").exists())
        new File(SystemUtils.JAVA_IO_TMPDIR, "export.jar").delete();
    if (BuilderConfig.getInstance().isAutosave())
        new com.flagleader.builder.d.c(localFlagLeader.builderManager).b();
    if (BuilderConfig.getInstance().isAutoCheckVersion())
        new a(localFlagLeader.builderManager).b();
    new e().b();
    localImage.dispose();
    localShell.dispose();
    localFlagLeader.open();
    BuilderManager localBuilderManager = localFlagLeader.builderManager;
    localFlagLeader.getShell().addShellListener(new d(localBuilderManager));
}

From source file:com.github.neoio.nio.impl.FileChannelIOStagingFactory.java

public FileChannelIOStagingFactory() {
    this(new SimpleDirectory(SystemUtils.JAVA_IO_TMPDIR));
}

From source file:com.intuit.cto.selfservice.service.Util.java

/**
 * @return true if the passed directory is within the system temporary directory
 *///from  www  .j  a  v  a  2 s .  c o  m
public static boolean isTemporaryDirectory(String directory) {
    return directory.startsWith(SystemUtils.JAVA_IO_TMPDIR);
}

From source file:com.twitter.common.logging.LogUtil.java

/**
 * Gets the log directory as specified in a log file pattern.  This will attempt to expand any
 * directory wildcards that are included in log file property.
 *
 * @param logFilePattern The pattern to extract the log directory from.
 * @return The configured log directory.
 *//*from  w ww .  j av  a2  s .  c  om*/
public static File getLogManagerLogDir(String logFilePattern) {
    if (StringUtils.isEmpty(logFilePattern)) {
        LOG.warning("Could not find log dir in logging property " + LOG_MANAGER_FILE_PROP + ", reading from "
                + DEFAULT_LOG_DIR);
        return DEFAULT_LOG_DIR;
    }

    String logDir = expandWildcard(logFilePattern, "%t", SystemUtils.JAVA_IO_TMPDIR);
    logDir = expandWildcard(logDir, "%h", SystemUtils.USER_HOME);
    File parent = new File(logDir).getParentFile();
    return parent == null ? new File(".") : parent;
}

From source file:com.ecyrd.jspwiki.util.ProviderConverter.java

protected void convert() throws WikiException, IOException {
    Properties props = new Properties();

    props.setProperty(WikiEngine.PROP_APPNAME, "JSPWikiConvert");
    props.setProperty(AbstractFileProvider.PROP_PAGEDIR, m_rcsSourceDir);
    props.setProperty(PageManager.PROP_PAGEPROVIDER, "RCSFileProvider");
    props.setProperty(PageManager.PROP_USECACHE, "false");
    props.setProperty("log4j.appender.outlog", "org.apache.log4j.ConsoleAppender");
    props.setProperty("log4j.appender.outlog.layout", "org.apache.log4j.PatternLayout");
    props.setProperty("jspwiki.useLucene", "false");
    props.setProperty("log4j.rootCategory", "INFO,outlog");
    WikiEngine engine = new WikiEngine(props);

    WikiPageProvider sourceProvider = engine.getPageManager().getProvider();

    File tmpDir = new File(SystemUtils.JAVA_IO_TMPDIR, "converter-tmp");

    props.setProperty(AbstractFileProvider.PROP_PAGEDIR, tmpDir.getAbsolutePath());
    WikiPageProvider destProvider = new VersioningFileProvider();

    destProvider.initialize(engine, props);

    Collection allPages = sourceProvider.getAllPages();

    int idx = 1;//from  ww  w  . j av a  2 s  .  co  m

    for (Iterator i = allPages.iterator(); i.hasNext();) {
        WikiPage p = (WikiPage) i.next();

        System.out.println("Converting page: " + p.getName() + " (" + idx + "/" + allPages.size() + ")");
        List pageHistory = engine.getVersionHistory(p.getName());

        for (ListIterator v = pageHistory.listIterator(pageHistory.size()); v.hasPrevious();) {
            WikiPage pv = (WikiPage) v.previous();

            String text = engine.getPureText(pv.getName(), pv.getVersion());

            destProvider.putPageText(pv, text);
        }

        //
        //  Do manual setting now
        //

        for (Iterator v = pageHistory.iterator(); v.hasNext();) {
            WikiPage pv = (WikiPage) v.next();

            File f = new File(tmpDir, "OLD");
            f = new File(f, mangleName(pv.getName()));
            f = new File(f, pv.getVersion() + ".txt");

            System.out
                    .println("   Setting old version " + pv.getVersion() + " to date " + pv.getLastModified());
            f.setLastModified(pv.getLastModified().getTime());
        }

        idx++;
    }

    tmpDir.delete();
}

From source file:com.alibaba.ims.platform.util.ExcelUtil.java

/**
 *  Excel//from   w w w  .ja v  a  2s . co m
 *
 * @param rows ?
 * @param path 
 * @param fileName ??
 * @return
 * @throws Exception
 */
public static File Write(List<List<String>> rows, String path, String fileName) throws IOException {
    if (CollectionUtils.isEmpty(rows)) {
        return null;
    }

    if (StringUtils.isBlank(path)) {
        path = SystemUtils.JAVA_IO_TMPDIR;
    }

    File parent = new File(path);
    if (!parent.exists()) {
        @SuppressWarnings("unused")
        boolean b = parent.mkdirs();
    }

    if (StringUtils.isBlank(fileName)) {
        fileName = UUID.randomUUID().toString();
    }

    File target = new File(path + File.separator + fileName + ".xslx");
    try {
        write(rows, target);
    } catch (IOException e) {
        logger.error("Write content to excel file error.", e);
        throw e;
    }
    return target;
}

From source file:com.yahoo.flowetl.commons.runner.Main.java

/**
 * Gets some useful runtime info as a map of names -> info.
 *///w  w  w .  j a v a2 s.  co m
private static Map<String, Object> getRuntimeInfo() {
    Map<String, Object> sysInfo = new TreeMap<String, Object>();
    StringBuilder jvminfo = new StringBuilder();
    jvminfo.append("Vendor: ");
    jvminfo.append(SystemUtils.JAVA_VENDOR);
    jvminfo.append(", Version: ");
    jvminfo.append(SystemUtils.JAVA_VERSION + " - " + SystemUtils.JAVA_VM_INFO);
    jvminfo.append(", OS: ");
    jvminfo.append(SystemUtils.OS_NAME + " (" + SystemUtils.OS_VERSION + " : " + SystemUtils.OS_ARCH + ")");
    sysInfo.put(WordUtils.capitalizeFully("jvm"), jvminfo.toString());
    sysInfo.put(WordUtils.capitalizeFully("default charset encoding"), DEF_CHAR_SET.name());
    String netAdd = NetUtils.getLocalAddress();
    if (StringUtils.isEmpty(netAdd)) {
        netAdd = "????";
    }
    String localName = NetUtils.getLocalHostName();
    if (StringUtils.isEmpty(localName)) {
        localName = "????";
    }
    sysInfo.put(WordUtils.capitalizeFully("network"), localName + " at ip address " + netAdd);
    String cPath = SystemUtils.JAVA_CLASS_PATH;
    String linesep = StringEscapeUtils.escapeJava(SystemUtils.LINE_SEPARATOR);
    sysInfo.put(WordUtils.capitalizeFully("classpath"), cPath);
    sysInfo.put(WordUtils.capitalizeFully("jvm home"), SystemUtils.JAVA_HOME);
    sysInfo.put(WordUtils.capitalizeFully("jvm tmpdir"), SystemUtils.JAVA_IO_TMPDIR);
    sysInfo.put(WordUtils.capitalizeFully("jvm libpath"), SystemUtils.JAVA_LIBRARY_PATH);
    sysInfo.put(WordUtils.capitalizeFully("line separator"), linesep);
    sysInfo.put(WordUtils.capitalizeFully("path separator"),
            StringEscapeUtils.escapeJava(SystemUtils.PATH_SEPARATOR));
    sysInfo.put(WordUtils.capitalizeFully("user timezone"), SystemUtils.USER_TIMEZONE);
    sysInfo.put(WordUtils.capitalizeFully("user home"), SystemUtils.USER_HOME);
    sysInfo.put(WordUtils.capitalizeFully("user language"), SystemUtils.USER_LANGUAGE);
    sysInfo.put(WordUtils.capitalizeFully("user name"), SystemUtils.USER_NAME);
    return sysInfo;
}

From source file:com.flagleader.builder.BuilderConfig.java

public String getTempPath() {
    if (this.o.length() == 0) {
        if (new File(this.p + File.separator + "temp").exists())
            return this.p + File.separator + "temp";
        try {//from ww w  .j  ava  2s  . com
            File localFile = new File(SystemUtils.JAVA_IO_TMPDIR, "dimages.jar");
            StreamUtil.pump(BuilderConfig.class.getClassLoader().getResource("dimages.jar").openStream(),
                    new FileOutputStream(localFile));
            jarExtracting(SystemUtils.JAVA_IO_TMPDIR, localFile.getPath());
            setTempPath(SystemUtils.JAVA_IO_TMPDIR);
        } catch (Exception localException) {
            return SystemUtils.JAVA_IO_TMPDIR;
        }
    }
    return this.o;
}

From source file:edu.duke.cabig.c3pr.web.security.SecureWebServiceHandler.java

/**
 * Store the certificate in a temporary file for further investigation.
 * //from www . j a  v a 2s  .  c  o m
 * @param cert
 */
private void store(X509Certificate cert, boolean binary) {
    try {
        byte[] buf = cert.getEncoded();
        final File file = new File(SystemUtils.JAVA_IO_TMPDIR,
                "Certificate_" + System.currentTimeMillis() + ".crt");
        log.error("Storing X.509 certificate in the file: " + file.getCanonicalPath());
        OutputStream os = new FileOutputStream(file);
        if (binary) {
            os.write(buf);
            os.flush();
        } else {
            Writer wr = new OutputStreamWriter(os, Charset.forName("UTF-8"));
            wr.write("-----BEGIN CERTIFICATE-----\n");
            wr.write(new sun.misc.BASE64Encoder().encode(buf));
            wr.write("\n-----END CERTIFICATE-----\n");
            wr.flush();
        }
        os.close();
    } catch (Exception e) {
        log.info(e.toString(), e);
    }
}

From source file:edu.duke.cabig.c3pr.webservice.integration.C3PREmbeddedTomcatTestBase.java

/**
 * Will create a bunch of directories, test required files for existence.
 * //from   w  w  w .j a  va2s. c  o m
 * @throws IOException
 */
private void initializeProperties() throws IOException {
    initCatalinaHome();

    initDataSourceFile();
    warFile = getFileFromProperty("test.war.file");

    webappsDir = new File(catalinaHome, "webapps");
    FileUtils.forceMkdir(webappsDir);

    confDir = new File(catalinaHome, "conf");
    FileUtils.forceMkdir(confDir);

    // we derive temp dir's name from the timestamp, which has insignificant
    // risk of collision; so it's fine: such names are more readable.
    tmpDir = new File(SystemUtils.JAVA_IO_TMPDIR,
            DateFormatUtils.format(new Date(), "yyyy_MM_dd_HH_mm_ss_SSS"));
    FileUtils.forceMkdir(tmpDir);

    rulesDir = new File(tmpDir, "rules");
    FileUtils.forceMkdir(rulesDir);

    logger.info(toString());

}