Example usage for java.lang System getProperty

List of usage examples for java.lang System getProperty

Introduction

In this page you can find the example usage for java.lang System getProperty.

Prototype

public static String getProperty(String key) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:com.tacitknowledge.util.migration.jdbc.MigrationTableUnlock.java

/**
 * Get the migration level information for the given system name
 *
 * @param arguments the command line arguments, if any (none are used)
 * @throws Exception if anything goes wrong
 *///  w w w  .ja v a 2 s. c  om
public static void main(String[] arguments) throws Exception {
    MigrationTableUnlock unlock = new MigrationTableUnlock();
    String migrationName = System.getProperty("migration.systemname");
    if (migrationName == null) {
        if ((arguments != null) && (arguments.length > 0)) {
            migrationName = arguments[0].trim();
        } else {
            throw new IllegalArgumentException("The migration.systemname " + "system property is required");
        }
    }
    unlock.tableUnlock(migrationName);
}

From source file:CAList.java

/**
 * <p><!-- Method description --></p>
 *
 *
 * @param args/*from   w w  w  . j  av  a2  s.com*/
 */
public static void main(String[] args) {
    try {
        // Load the JDK's cacerts keystore file
        String filename = System.getProperty("java.home")
                + "/lib/security/cacerts".replace('/', File.separatorChar);
        FileInputStream is = new FileInputStream(filename);
        KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
        String password = "changeit";
        keystore.load(is, password.toCharArray());

        // This class retrieves the most-trusted CAs from the keystore
        PKIXParameters params = new PKIXParameters(keystore);

        // Get the set of trust anchors, which contain the most-trusted CA certificates
        Iterator it = params.getTrustAnchors().iterator();
        for (; it.hasNext();) {
            TrustAnchor ta = (TrustAnchor) it.next();

            // Get certificate
            X509Certificate cert = ta.getTrustedCert();
            System.out.println("<issuer>" + cert.getIssuerDN() + "</issuer>\n");
        }
    } catch (CertificateException e) {
    } catch (KeyStoreException e) {
    } catch (NoSuchAlgorithmException e) {
    } catch (InvalidAlgorithmParameterException e) {
    } catch (IOException e) {
    }
}

From source file:com.revo.deployr.client.example.data.io.auth.stateful.preload.EncodedDataInBinaryFileOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;/* w  w w  .  j  a  va  2 s  .  co m*/
    RProject rProject = null;

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Build a basic authentication token.
         */
        RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"),
                System.getProperty("password"));

        /*
         * Establish an authenticated handle with the DeployR
         * server, rUser. Following this call the rClient 
         * connection is operating as an authenticated connection
         * and all calls on rClient inherit the access permissions
         * of the authenticated user, rUser.
         */
        RUser rUser = rClient.login(rAuth);
        log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ].");

        /*
         * Create a ProjectCreationOptions instance
         * to specify data inputs that "pre-heat" the R session
         * workspace or working directory for your project.
         */
        ProjectCreationOptions options = new ProjectCreationOptions();

        /* 
         * Simulate application generated data. This data
         * is first encoded using the RDataFactory before
         * being passed as an input on project initialization.
         *
         * This encoded R input is automatically converted
         * into a workspace object at project initialization.
         */
        RData generatedData = simulateGeneratedData();
        if (generatedData != null) {
            List<RData> rinputs = Arrays.asList(generatedData);
            options.rinputs = rinputs;
        }

        log.info("[ PRELOAD INPUT  ] DeployR-encoded R input set on "
                + "project creation, [ ProjectCreationOptions.rinputs ].");

        /*
         * Create a temporary project (R session) passing a 
         * ProjectCreationOptions to "pre-heat" data into the
         * workspace and/or working directory.
         */
        rProject = rUser.createProject(options);

        log.info("[  GO STATEFUL   ] Created stateful temporary " + "R session [ RProject ].");

        /*
         * Execute a public analytics Web service as an authenticated
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RProjectExecution exec = rProject.executeScript("dataIO.R", "example-data-io", "testuser", null, null);

        log.info("[   EXECUTION    ] Stateful R script " + "execution completed [ RProjectExecution ].");

        /*
         * Retrieve the working directory file (artifact) called
         * hip.rData that was generated by the execution.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RProjectFile> wdFiles = exec.about().artifacts;

        for (RProjectFile wdFile : wdFiles) {
            if (wdFile.about().filename.equals("hip.rData")) {
                log.info("[  DATA OUTPUT   ] Retrieved working directory " + "file output "
                        + wdFile.about().filename + " [ RProjectFile ].");
                InputStream fis = null;
                try {
                    fis = wdFile.download();
                } catch (Exception ex) {
                    log.warn("Working directory binary file download " + ex);
                } finally {
                    IOUtils.closeQuietly(fis);
                }
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rProject != null) {
                /*
                 * Close rProject before application exits.
                 */
                rProject.close();
            }
        } catch (Exception fex) {
        }
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:example.wildcard.Client.java

public static void main(String[] args) {
    String url = BROKER_URL;
    if (args.length > 0) {
        url = args[0].trim();/*from   w  w  w .  j a  v  a 2  s.  c  om*/
    }
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", url);
    Connection connection = null;

    try {
        Topic senderTopic = new ActiveMQTopic(System.getProperty("topicName"));

        connection = connectionFactory.createConnection("admin", "password");

        Session senderSession = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE);
        MessageProducer sender = senderSession.createProducer(senderTopic);

        Session receiverSession = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE);

        String policyType = System.getProperty("wildcard", ".*");
        String receiverTopicName = senderTopic.getTopicName() + policyType;
        Topic receiverTopic = receiverSession.createTopic(receiverTopicName);

        MessageConsumer receiver = receiverSession.createConsumer(receiverTopic);
        receiver.setMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                try {
                    if (message instanceof TextMessage) {
                        String text = ((TextMessage) message).getText();
                        System.out.println("We received a new message: " + text);
                    }
                } catch (JMSException e) {
                    System.out.println("Could not read the receiver's topic because of a JMSException");
                }
            }
        });

        connection.start();
        System.out.println("Listening on '" + receiverTopicName + "'");
        System.out.println("Enter a message to send: ");

        Scanner inputReader = new Scanner(System.in);

        while (true) {
            String line = inputReader.nextLine();
            if (line == null) {
                System.out.println("Done!");
                break;
            } else if (line.length() > 0) {
                try {
                    TextMessage message = senderSession.createTextMessage();
                    message.setText(line);
                    System.out.println("Sending a message: " + message.getText());
                    sender.send(message);
                } catch (JMSException e) {
                    System.out.println("Exception during publishing a message: ");
                }
            }
        }

        receiver.close();
        receiverSession.close();
        sender.close();
        senderSession.close();

    } catch (Exception e) {
        System.out.println("Caught exception!");
    } finally {
        if (connection != null) {
            try {
                connection.close();
            } catch (JMSException e) {
                System.out.println("When trying to close connection: ");
            }
        }
    }

}

From source file:com.revo.deployr.client.example.data.io.anon.discrete.exec.MultipleDataInMultipleDataOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;//w  w  w.  ja v  a  2 s . c o m

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Create the AnonymousProjectExecutionOptions object
         * to specify data inputs and output to the script.
         *
         * This options object can be used to pass standard
         * execution model parameters on execution calls. All
         * fields are optional.
         *
         * See the Standard Execution Model chapter in the
         * Client Library Tutorial on the DeployR website for
         * further details.
         */
        AnonymousProjectExecutionOptions options = new AnonymousProjectExecutionOptions();

        /*
         * MultipleDataInMultipleDataOut Example Note:
         * 
         * The inputs sent on this example are contrived
         * and superfluous as the hipStar.rData binary R
         * object input and the hipStarUrl input perform
         * the exact same purpose...to load the Hip STAR
         * dataset into the workspace ahead of execution.
         * 
         * The example is provided to simply demonstrate
         * the mechanism of specifying multiple inputs.
         */

        /* 
         * Preload from the DeployR repository the following
         * binary R object input file:
         * /testuser/example-data-io/hipStar.rData
         *
         * As this is an anonymous operation "hipStar.rData"
         * must have it's repository-managed access controls
         * set to "public".
         */
        ProjectPreloadOptions preloadWorkspace = new ProjectPreloadOptions();
        preloadWorkspace.filename = "hipStar.rData";
        preloadWorkspace.directory = "example-data-io";
        preloadWorkspace.author = "testuser";
        options.preloadWorkspace = preloadWorkspace;

        log.info("[   DATA INPUT   ] Repository binary file input "
                + "set on execution, [ ProjectExecutionOptions.preloadWorkspace ].");

        /* 
         * Load an R object literal "hipStarUrl" into the
         * workspace prior to script execution.
         *
         * The R script checks for the existence of "hipStarUrl"
         * in the workspace and if present uses the URL path
         * to load the Hipparcos star dataset from the DAT file
         * at that location.
         */
        RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL);
        List<RData> rinputs = Arrays.asList(hipStarUrl);
        options.rinputs = rinputs;

        log.info("[   DATA INPUT   ] External data source input "
                + "set on execution, [ ProjectPreloadOptions.rinputs ].");

        /*
         * Request the retrieval of the "hip" data.frame and
         * two vector objects from the workspace following the
         * execution. The corresponding R objects are named as
         * follows:
         * 'hip', hipDim', 'hipNames'.
         */
        options.routputs = Arrays.asList("hip", "hipDim", "hipNames");

        log.info("[  EXEC OPTION   ] DeployR-encoded R object request "
                + "set on execution [ ProjectExecutionOptions.routputs ].");

        /*
         * Execute a public analytics Web service as an anonymous
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RScriptExecution exec = rClient.executeScript("dataIO.R", "example-data-io", "testuser", null, options);

        log.info("[   EXECUTION    ] Discrete R script " + "execution completed [ RScriptExecution ].");

        /*
         * Retrieve multiple outputs following the execution:
         *
         * 1. R console output.
         * 2. R console output.
         * 3. R console output.
         * 4. R console output.
         * 5. R console output.
         */

        String console = exec.about().console;
        log.info("[  DATA OUTPUT   ] Retrieved R console " + "output [ String ].");

        /*
         * Retrieve the requested R object data encodings from
         * the workspace follwing the script execution. 
         *
         * See the R Object Data Decoding chapter in the
         * Client Library Tutorial on the DeployR website for
         * further details.
         */
        List<RData> objects = exec.about().workspaceObjects;

        for (RData rData : objects) {
            if (rData instanceof RDataFrame) {
                log.info("[  DATA OUTPUT   ] Retrieved DeployR-encoded R " + "object output " + rData.getName()
                        + " [ RDataFrame ].");
                List<RData> hipSubsetVal = ((RDataFrame) rData).getValue();
            } else if (rData instanceof RNumericVector) {
                log.info("[  DATA OUTPUT   ] Retrieved DeployR-encoded R " + "object output " + rData.getName()
                        + " [ RNumericVector ].");
                List<Double> hipDimVal = ((RNumericVector) rData).getValue();
                log.info("[  DATA OUTPUT   ] Retrieved DeployR-encoded R " + "object " + rData.getName()
                        + " value=" + hipDimVal);
            } else if (rData instanceof RStringVector) {
                log.info("[  DATA OUTPUT   ] Retrieved DeployR-encoded R " + "object output " + rData.getName()
                        + " [ RStringVector ].");
                List<String> hipNamesVal = ((RStringVector) rData).getValue();
                log.info("[  DATA OUTPUT   ] Retrieved DeployR-encoded R " + "object " + rData.getName()
                        + " value=" + hipNamesVal);
            } else {
                log.info("Unexpected DeployR-encoded R object returned, " + "object name=" + rData.getName()
                        + ", encoding=" + rData.getClass());
            }
        }

        /*
         * Retrieve the working directory files (artifact)
         * was generated by the execution.
         */
        List<RProjectFile> wdFiles = exec.about().artifacts;

        for (RProjectFile wdFile : wdFiles) {
            log.info("[  DATA OUTPUT   ] Retrieved working directory " + "file output "
                    + wdFile.about().filename + " [ RProjectFile ].");
            InputStream fis = null;
            try {
                fis = wdFile.download();
            } catch (Exception ex) {
                log.warn("Working directory binary file " + ex);
            } finally {
                IOUtils.closeQuietly(fis);
            }
        }

        /*
         * Retrieve R graphics device plots (results) called
         * unnamedplot*.png that was generated by the execution.
         */
        List<RProjectResult> results = exec.about().results;

        for (RProjectResult result : results) {
            log.info("[  DATA OUTPUT   ] Retrieved graphics device " + "plot output " + result.about().filename
                    + " [ RProjectResult ].");
            InputStream fis = null;
            try {
                fis = result.download();
            } catch (Exception ex) {
                log.warn("Graphics device plot " + ex);
            } finally {
                IOUtils.closeQuietly(fis);
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:com.tacitknowledge.util.migration.jdbc.DistributedMigrationTableUnlock.java

/**
 * Get the migration level information for the given system name
 *
 * @param arguments the command line arguments, if any (none are used)
 * @throws Exception if anything goes wrong
 *//*  w  w  w .j av  a  2 s . c  o  m*/
public static void main(String[] arguments) throws Exception {
    DistributedMigrationTableUnlock unlock = new DistributedMigrationTableUnlock();
    String migrationName = System.getProperty("migration.systemname");
    if (migrationName == null) {
        if ((arguments != null) && (arguments.length > 0)) {
            migrationName = arguments[0].trim();
        } else {
            throw new IllegalArgumentException("The migration.systemname " + "system property is required");
        }
    }
    unlock.tableUnlock(migrationName);
}

From source file:com.revo.deployr.client.example.data.io.auth.stateful.preload.ExternalDataInDataFileOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;//from   w  w w .  ja va2  s.  c  o m
    RProject rProject = null;

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Build a basic authentication token.
         */
        RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"),
                System.getProperty("password"));

        /*
         * Establish an authenticated handle with the DeployR
         * server, rUser. Following this call the rClient 
         * connection is operating as an authenticated connection
         * and all calls on rClient inherit the access permissions
         * of the authenticated user, rUser.
         */
        RUser rUser = rClient.login(rAuth);
        log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ].");

        /*
         * Create a ProjectCreationOptions instance
         * to specify data inputs that "pre-heat" the R session
         * workspace or working directory for your project.
         */
        ProjectCreationOptions options = new ProjectCreationOptions();

        /* 
         * Load an R object literal "hipStarUrl" into the
         * workspace on project initialization.
         *
         * The R script execution that follows will check for
         * the existence of "hipStarUrl" in the workspace and if
         * present uses the URL path to load the Hipparcos star
         * dataset from the DAT file at that location.
         */
        RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL);
        List<RData> rinputs = Arrays.asList(hipStarUrl);
        options.rinputs = rinputs;

        log.info("[ PRELOAD INPUT  ] External data source input "
                + "set on project creation, [ ProjectCreationOptions.rinputs ].");

        /*
         * Create a temporary project (R session) passing a 
         * ProjectCreationOptions to "pre-heat" data into the
         * workspace and/or working directory.
         */
        rProject = rUser.createProject(options);

        log.info("[  GO STATEFUL   ] Created stateful temporary " + "R session [ RProject ].");

        /*
         * Execute a public analytics Web service as an authenticated
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RProjectExecution exec = rProject.executeScript("dataIO.R", "example-data-io", "testuser", null, null);

        log.info("[   EXECUTION    ] Stateful R script " + "execution completed [ RProjectExecution ].");

        /*
         * Retrieve the working directory file (artifact) called
         * hip.csv that was generated by the execution.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RProjectFile> wdFiles = exec.about().artifacts;

        for (RProjectFile wdFile : wdFiles) {
            if (wdFile.about().filename.equals("hip.csv")) {
                log.info("[  DATA OUTPUT   ] Retrieved working directory " + "file output "
                        + wdFile.about().filename + " [ RProjectFile ].");
                InputStream fis = null;
                try {
                    fis = wdFile.download();
                } catch (Exception ex) {
                    log.warn("Working directory data file download " + ex);
                } finally {
                    IOUtils.closeQuietly(fis);
                }
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rProject != null) {
                /*
                 * Close rProject before application exits.
                 */
                rProject.close();
            }
        } catch (Exception fex) {
        }
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:com.xinge.sample.samples.docx4j.org.docx4j.samples.OpenUnzippedAndSaveZipped.java

public static void main(String[] args) throws Exception {

    try {/*from w  ww .  j  a v  a2  s .c  o m*/
        getInputFilePath(args);
    } catch (IllegalArgumentException e) {
        inputfilepath = System.getProperty("user.dir") + "/OUT";
    }
    System.out.println(inputfilepath);

    // Load the docx
    File baseDir = new File(inputfilepath);
    UnzippedPartStore partLoader = new UnzippedPartStore(baseDir);
    final Load3 loader = new Load3(partLoader);
    OpcPackage opc = loader.get();

    // Save it zipped
    File docxFile = new File(System.getProperty("user.dir") + "/zip.docx");

    ZipPartStore zps = new ZipPartStore();
    zps.setSourcePartStore(opc.getSourcePartStore());

    Save saver = new Save(opc, zps);
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(docxFile);
        saver.save(fos);
    } catch (FileNotFoundException e) {
        throw new Docx4JException("Couldn't save " + docxFile.getPath(), e);
    } finally {
        IOUtils.closeQuietly(fos);
    }

}

From source file:com.revo.deployr.client.example.data.io.auth.stateful.exec.EncodedDataInBinaryFileOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;/*from  w ww  . j  av  a 2  s.  c  o  m*/
    RProject rProject = null;

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Build a basic authentication token.
         */
        RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"),
                System.getProperty("password"));

        /*
         * Establish an authenticated handle with the DeployR
         * server, rUser. Following this call the rClient 
         * connection is operating as an authenticated connection
         * and all calls on rClient inherit the access permissions
         * of the authenticated user, rUser.
         */
        RUser rUser = rClient.login(rAuth);
        log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ].");

        /*
         * Create a temporary project (R session).
         *
         * Optionally:
         * ProjectCreationOptions options =
         * new ProjectCreationOptions();
         *
         * Populate options as needed, then:
         *
         * rProject = rUser.createProject(options);
         */
        rProject = rUser.createProject();

        log.info("[  GO STATEFUL   ] Created stateful temporary " + "R session [ RProject ].");

        /*
         * Create a ProjectExecutionOptions instance
         * to specify data inputs and output to the
         * execution of the repository-managed R script.
         *
         * This options object can be used to pass standard
         * execution model parameters on execution calls. All
         * fields are optional.
         *
         * See the Standard Execution Model chapter in the
         * Client Library Tutorial on the DeployR website for
         * further details.
         */
        ProjectExecutionOptions options = new ProjectExecutionOptions();

        /* 
         * Simulate application generated data. This data
         * is first encoded using the RDataFactory before
         * being passed as an input on the execution.
         *
         * This encoded R input is automatically converted
         * into a workspace object before script execution.
         */
        RData generatedData = simulateGeneratedData();
        if (generatedData != null) {
            List<RData> rinputs = Arrays.asList(generatedData);
            options.rinputs = rinputs;
        }

        log.info("[   DATA INPUT   ] DeployR-encoded R input set on execution, "
                + "[ ProjectExecutionOptions.rinputs ].");

        /*
         * Execute a public analytics Web service as an authenticated
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RProjectExecution exec = rProject.executeScript("dataIO.R", "example-data-io", "testuser", null,
                options);

        log.info("[   EXECUTION    ] Stateful R script " + "execution completed [ RProjectExecution ].");

        /*
         * Retrieve the working directory file (artifact) called
         * hip.rData that was generated by the execution.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RProjectFile> wdFiles = exec.about().artifacts;

        for (RProjectFile wdFile : wdFiles) {
            if (wdFile.about().filename.equals("hip.rData")) {
                log.info("[  DATA OUTPUT   ] Retrieved working directory " + "file output "
                        + wdFile.about().filename + " [ RProjectFile ].");
                InputStream fis = null;
                try {
                    fis = wdFile.download();
                } catch (Exception ex) {
                    log.warn("Working directory binary file download " + ex);
                } finally {
                    IOUtils.closeQuietly(fis);
                }
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rProject != null) {
                /*
                 * Close rProject before application exits.
                 */
                rProject.close();
            }
        } catch (Exception fex) {
        }
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:com.unifil.agendapaf.exemplos.word.ConvertInXHTMLFile.java

public static void main(String[] args) throws Exception {

    String inputfilepath = "DocxToXhtmlAndBack.html";
    //        String baseURL = "file:///C:/Users/jharrop/git/docx4j-ImportXHTML/somedir/";
    String baseURL = "file:/" + System.getProperty("user.dir") + "/docx/";
    System.out.println("baseURL " + baseURL);
    String stringFromFile = FileUtils.readFileToString(new File("docx/" + inputfilepath), "UTF-8");

    String unescaped = stringFromFile;
    //        if (stringFromFile.contains("&lt;/") ) {
    //          unescaped = StringEscapeUtils.unescapeHtml(stringFromFile);           
    //        }//from w w  w  .j a v  a  2  s  .  c  o  m

    //        XHTMLImporter.setTableFormatting(FormattingOption.IGNORE_CLASS);
    //        XHTMLImporter.setParagraphFormatting(FormattingOption.IGNORE_CLASS);
    System.out.println("Unescaped: " + unescaped);

    // Setup font mapping
    RFonts rfonts = Context.getWmlObjectFactory().createRFonts();
    rfonts.setAscii("Century Gothic");
    XHTMLImporterImpl.addFontMapping("Century Gothic", rfonts);

    // Create an empty docx package
    //      WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File("docx/" + "styled.docx"));

    NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
    wordMLPackage.getMainDocumentPart().addTargetPart(ndp);
    ndp.unmarshalDefaultNumbering();

    // Convert the XHTML, and add it into the empty docx we made
    XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
    XHTMLImporter.setHyperlinkStyle("Hyperlink");
    wordMLPackage.getMainDocumentPart().getContent().addAll(XHTMLImporter.convert(unescaped, baseURL));

    System.out.println(
            XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true));

    //      System.out.println(
    //            XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getNumberingDefinitionsPart().getJaxbElement(), true, true));
    wordMLPackage.save(new java.io.File("docx/" + "OUT_from_XHTML.docx"));

}