Example usage for java.io FileWriter flush

List of usage examples for java.io FileWriter flush

Introduction

In this page you can find the example usage for java.io FileWriter flush.

Prototype

public void flush() throws IOException 

Source Link

Document

Flushes the stream.

Usage

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.IntDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set//from  www  .j  a  v  a2  s  .  co  m
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        IntDataType searchObject = new IntDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.IntDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            IntDataType obj = (IntDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/IntDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("IntDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.IvlIntDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set/*from w w w  . ja va2s  .  c  o m*/
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        IvlIntDataType searchObject = new IvlIntDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.IvlIntDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            IvlIntDataType obj = (IvlIntDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/IvlIntDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("IvlIntDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.IvlPqDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set//from www  . jav a2s  . co m
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        IvlPqDataType searchObject = new IvlPqDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.IvlPqDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            IvlPqDataType obj = (IvlPqDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/IvlPqDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("IvlPqDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.IvlRealDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set//from w w w  .  j a  v a2  s .c  o m
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        IvlRealDataType searchObject = new IvlRealDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.IvlRealDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            IvlRealDataType obj = (IvlRealDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/IvlRealDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("IvlRealDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.IvlTsDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set//from w ww . j a va  2s. c om
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        IvlTsDataType searchObject = new IvlTsDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.IvlTsDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            IvlTsDataType obj = (IvlTsDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/IvlTsDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("IvlTsDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.PqDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set//from  www.j a v a 2s.com
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        PqDataType searchObject = new PqDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.PqDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            PqDataType obj = (PqDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/PqDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("PqDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.RealDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set//  w  w w.  j a  v a2  s  .c  o  m
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        RealDataType searchObject = new RealDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.RealDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            RealDataType obj = (RealDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/RealDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("RealDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.ScDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set/*w w w .j  a  v  a  2 s.  c om*/
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        ScDataType searchObject = new ScDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.ScDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            ScDataType obj = (ScDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/ScDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("ScDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.StDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set/*from  w  w  w .  j av  a  2 s.c  om*/
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        StDataType searchObject = new StDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.StDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            StDataType obj = (StDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/StDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("StDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.other.datatype.StNtDataTypeResourceTest.java

/**
 * Uses Nested Search Criteria for search
 * Verifies that the results are returned 
 * Verifies size of the result set/*from w w  w .  ja v  a 2 s. c  o m*/
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

        StNtDataType searchObject = new StNtDataType();
        Collection results = getApplicationService()
                .search("gov.nih.nci.cacoresdk.domain.other.datatype.StNtDataType", searchObject);
        String id = "";

        if (results != null && results.size() > 0) {
            StNtDataType obj = (StNtDataType) ((List) results).get(0);

            Integer idVal = obj.getId();
            id = new Integer(idVal).toString();

        } else
            return;

        if (id.equals(""))
            return;

        String url = baseURL + "/rest/StNtDataType/" + id;

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("StNtDataType" + "XML.xml");

        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }

}