Code example for DataOutputStream

Methods: close, flush, sleep, write, writeBytes

0
            assert tmp != null;
            String sampleReturnResponse = "<testResponse>\n" +
                                          "   <message>" + tmp.toUpperCase() + "Success</message>\n" +
                                          " </testResponse>"; 
 
            output.writeBytes(constructHttpHeader(expectedResponseCode, contentType));
            output.write(sampleReturnResponse.getBytes());
        } catch (Exception e) {
            log.error("error" + e.getMessage());
        } finally { 
            output.flush();
            Thread.sleep(1000);
            input.close();
            output.close();
        } 
    } 
 
    private String constructHttpHeader(int returnCode, String contentType) {
        String header = "HTTP/1.0 ";
        switch (returnCode) {
            case 200: