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.TelDataTypeResourceTest.java

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

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/TelDataType/" + 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("TelDataType" + "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.TelEmailDataTypeResourceTest.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 va2  s  . co m*/
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/TelEmailDataType/" + 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("TelEmailDataType" + "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.TelPersonDataTypeResourceTest.java

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

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/TelPersonDataType/" + 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("TelPersonDataType" + "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.TelPhoneDataTypeResourceTest.java

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

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/TelPhoneDataType/" + 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("TelPhoneDataType" + "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.TelUrlDataTypeResourceTest.java

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

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/TelUrlDataType/" + 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("TelUrlDataType" + "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.TsDataTypeResourceTest.java

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

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/TsDataType/" + 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("TsDataType" + "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.primarykey.CharacterKeyResourceTest.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  . co m
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/CharacterKey/" + 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("CharacterKey" + "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.primarykey.CharacterPrimitiveKeyResourceTest.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  .co  m
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/CharacterPrimitiveKey/" + 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("CharacterPrimitiveKey" + "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.primarykey.DoubleKeyResourceTest.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  2s .  com*/
 * Verifies that none of the attributes are null
 * 
 * @throws Exception
 */
public void testGet() throws Exception {

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/DoubleKey/" + 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("DoubleKey" + "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.primarykey.DoublePrimitiveKeyResourceTest.java

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

    try {

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

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

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

        } else
            return;

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

        String url = baseURL + "/rest/DoublePrimitiveKey/" + 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("DoublePrimitiveKey" + "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;
    }

}