Java HTTP Port Find getXmlReport(String fileName)

Here you can find the source of getXmlReport(String fileName)

Description

Ucitava dati izvestaj preko servleta.

License

Open Source License

Declaration

public static String getXmlReport(String fileName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Main {
    private static String reportServletUrl;

    /**//ww w . j  a  va 2 s  .  c o m
     * Ucitava dati izvestaj preko servleta.
     */
    public static String getXmlReport(String fileName) {
        String proxyHost = System.getProperty("proxyHost");
        String proxyPort = System.getProperty("proxyHost");
        System.setProperty("proxyHost", "");
        System.setProperty("proxyPort", "");
        System.setProperty("proxySet", "false");
        StringBuffer buff = new StringBuffer();
        try {

            URL url = new URL(reportServletUrl + "?reportFile=" + fileName);
            URLConnection conn = url.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    conn.getInputStream(), "UTF8"));

            String line = "";
            while ((line = in.readLine()) != null) {
                buff.append(line + "\n");

            }
            in.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        System.setProperty("proxyHost", proxyHost == null ? "" : proxyHost);
        System.setProperty("proxyPort", proxyPort == null ? "" : proxyPort);
        System.setProperty("proxySet", proxyHost == null ? "false" : "true");

        return buff.toString();
    }

    /**
     * Ucitava dati izvestaj iz fajl sistema.
     */
    public static String getXmlReport(String fileName, String dir) {
        File d = new File(dir);
        File f = new File(d, fileName);
        StringBuffer buff = new StringBuffer();
        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    new FileInputStream(f), "UTF8"));
            String line = "";
            while ((line = in.readLine()) != null)
                buff.append(line + "\n");
            in.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return buff.toString();
    }
}

Related

  1. getUnusedPort(final int start)
  2. getUnusedPort(int startPort)
  3. getUnusedPorts(final int count, final int start)
  4. getValidZooKeeperPort()
  5. getWsdlLocation(String portPrefix)
  6. hasPermissionToBindPort(int port)
  7. isActivePort(int port)
  8. isAlive(String hostname, int port, int retries)
  9. isAvailablePort(int port)