Example usage for java.util Properties save

List of usage examples for java.util Properties save

Introduction

In this page you can find the example usage for java.util Properties save.

Prototype

@Deprecated
public void save(OutputStream out, String comments) 

Source Link

Document

Calls the store(OutputStream out, String comments) method and suppresses IOExceptions that were thrown.

Usage

From source file:nf.frex.android.FrexActivity.java

private void writeFrexDoc(OutputStream stream) {
    Properties properties = new Properties();
    view.saveInstanceState(new DefaultPropertySet(properties));
    properties.save(stream, "Generated by Frex on " + new Date());
}

From source file:com.photon.phresco.impl.ATGApplicationProcessor.java

private void updateBuildProperties(File propertyFile, String moduleName) throws PhrescoException {
    Properties properties = new Properties();
    FileInputStream fis;//from  w  ww .j  a v a 2 s  .co  m
    try {
        fis = new FileInputStream(propertyFile);
        properties.load(fis);
        String moduleBuildOrder = properties.getProperty("modules.build.order");
        String module = moduleName + "/build.xml";
        if (StringUtils.isEmpty(moduleBuildOrder)) {
            properties.put("modules.build.order", module);

        } else {
            if (!moduleBuildOrder.contains(module)) {
                properties.put("modules.build.order", moduleBuildOrder.concat(",").concat(module));
            }
        }

        String moduleOrder = properties.getProperty("module.order");
        if (StringUtils.isEmpty(moduleOrder)) {
            properties.put("module.order", moduleName);
        } else {
            if (!moduleOrder.contains(moduleName)) {
                properties.put("module.order", moduleOrder + " " + moduleName);
            }
        }
        properties.save(new FileOutputStream(propertyFile), "");
    } catch (FileNotFoundException e) {
        throw new PhrescoException(e);
    } catch (IOException e) {
        throw new PhrescoException(e);
    }
}

From source file:controllers.Consumer.java

public static void vncConnection(final String vncAddress, final String vncPort, final String vncPassword) {
    Logger.info("---------INSIDE CONSUMER OFFERDETAILS()---------------");

    String user = session.get("username");
    if (user != null) {
        Logger.info("------------EXITING CONSUMER OFFERDETAILS()--------------");

        try {/* ww w.  java  2s  .c om*/
            // TODO: connect ssh to retrieve data from each vm

            Properties props = new Properties();
            // load a properties file
            props.load(new FileInputStream(Play.getFile("conf/config.properties")));

            final String noVNCPath = props.getProperty("noVNC");
            final String noVNCPort = props.getProperty("noVNCPort");
            final String noVNCServer = props.getProperty("noVNCServer");
            // final String sp = noVNCPath + "utils/websockify --web " +
            // noVNCPath + " " + noVNCPort + " " + vncAddress + ":" +
            // vncPort;
            ProcessBuilder pb = new ProcessBuilder("public/noVNC/utils/websockify", "--web", "public/noVNC/",
                    noVNCPort, vncAddress + ":" + vncPort);
            pb.redirectErrorStream(); // redirect stderr to stdout
            Process process = pb.start();
            play.mvc.Http.Request current = play.mvc.Http.Request.current();
            String url = current.url;
            String domain = current.domain;
            Integer newPortRaw = Integer.parseInt(noVNCPort);
            Integer newPort = newPortRaw == 6900 ? 6080 : newPortRaw + 1;

            props.setProperty("noVNCPort", newPort.toString());
            props.save(new FileOutputStream(new File("conf/config.properties")), "");
            render(vncAddress, vncPort, vncPassword, noVNCServer, noVNCPort, url, user, domain);
            // process.waitFor();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } else {

        flash.error("You are not connected.Please Login");
        Login.login_page();
    }
}

From source file:org.apache.jetspeed.modules.actions.portlets.designer.HeaderAction.java

public void doDefault(RunData rundata, Context context) throws Exception {
    try {/*from w  w  w.  j  a va  2  s  .  c om*/
        String logo = IMAGES_DIRECTORY + "jetspeed-logo.gif";
        String bgImage = "";
        String fontSize = "10";
        String title = "Jakarta Jetspeed";

        String DEFAULT_ROOT = File.separator + "WEB-INF" + File.separator + "conf" + File.separator;
        String root = rundata.getServletConfig().getServletContext().getRealPath(DEFAULT_ROOT) + File.separator;

        Properties prop = new Properties();
        prop.load(new FileInputStream(root + "JetspeedResources.properties"));
        prop.clone();

        TurbineResources trProp = (TurbineResources) TurbineResources
                .getResources(root + "JetspeedResources.properties");

        TurbineResources.setProperty("portal.title", title);
        prop.setProperty("portal.title", title);
        TurbineResources.setProperty("topnav.logo.file", logo);
        prop.setProperty("topnav.logo.file", logo);
        TurbineResources.setProperty("topnav.bg.image", "");
        prop.setProperty("topnav.bg.image", "");
        TurbineResources.setProperty("topnav.bg.color", "");
        prop.setProperty("topnav.bg.color", "");

        TurbineResources.setProperty("topnav.font.size", "");
        prop.setProperty("topnav.font.size", "");

        TurbineResources.setProperty("topnav.font.color", "");
        prop.setProperty("topnav.font.color", "");

        FileOutputStream stream = new FileOutputStream(root + "JetspeedResources.properties");

        prop.save(stream, "topnav.logo.file");

        prop.save(stream, "portal.title");
        prop.save(stream, "topnav.bg.image");
        prop.save(stream, "topnav.bg.color");
        prop.save(stream, "ptopnav.font.size");
        prop.save(stream, "ptopnav.font.size");
        stream.close();

        context.put("settingStatus", "Successfully changed to default settings.");
    } catch (Exception e) {
        context.put("settingStatus", "Error occurred while changing to default settings. ");
        log.error(e);
    }
}

From source file:org.apache.jk.common.HandlerRequest.java

private void generateAjp13Id() {
    int portInt = 8009; // tcpCon.getPort();
    InetAddress address = null; // tcpCon.getAddress();

    if (requiredSecret == null)
        return;//from  w w w . j  ava  2 s.c o  m

    File f1 = new File(wEnv.getJkHome());
    File f2 = new File(f1, "conf");

    if (!f2.exists()) {
        log.error("No conf dir for ajp13.id " + f2);
        return;
    }

    File sf = new File(f2, "ajp13.id");

    if (log.isDebugEnabled())
        log.debug("Using stop file: " + sf);

    try {
        Properties props = new Properties();

        props.put("port", Integer.toString(portInt));
        if (address != null) {
            props.put("address", address.getHostAddress());
        }
        if (requiredSecret != null) {
            props.put("secret", requiredSecret);
        }

        FileOutputStream stopF = new FileOutputStream(sf);
        props.save(stopF, "Automatically generated, don't edit");
    } catch (IOException ex) {
        log.debug("Can't create stop file: " + sf);
        ex.printStackTrace();
    }
}