@Test public void testSaveToFile() throws IOException { File outputFile = tempFolder.newFile("ReportOutput.csv"); String expectedContents = "a,b,c\nd,e,f\n"; InputStream inputStream = new ByteArrayInputStream(expectedContents.getBytes(UTF_8)); RawReportDownloadResponse rawResponse = new RawReportDownloadResponse(HttpURLConnection.HTTP_OK, inputStream, UTF_8, "CSV"); ReportDownloadResponse response = new ReportDownloadResponse(rawResponse); response.saveToFile(outputFile.getPath()); assertEquals("contents saved to file are incorrect", expectedContents, Streams.readAll(new FileInputStream(outputFile), UTF_8)); }
public void saveToFile(String outputFile) throws FileNotFoundException, IOException { Streams.copy(getInputStream(), new BufferedOutputStream(new FileOutputStream(outputFile))); }
ReportDownloadResponse { public void saveToFile(String outputFile) throws FileNotFoundException, IOException { Streams.copy(getInputStream(), new BufferedOutputStream(new FileOutputStream(outputFile))); } }
ReportDownloadResponse { public void saveToFile(String outputFile) throws FileNotFoundException, IOException { Streams.copy(getInputStream(), new BufferedOutputStream(new FileOutputStream(outputFile))); } ReportDownloadResponse(RawReportDownloadResponse rawResponse); }
ReportDownloadResponse { public void saveToFile(String outputFile) throws FileNotFoundException, IOException { Streams.copy(getInputStream(), new BufferedOutputStream(new FileOutputStream(outputFile))); } ReportDownloadResponse(RawReportDownloadResponse rawResponse); int getHttpStatus(); String getHttpResponseMessage(); @Nullable InputStream getInputStream(); String getAsString(); void saveToFile(String outputFile); }
ReportDownloadResponse { public void saveToFile(String outputFile) throws FileNotFoundException, IOException { Streams.copy(getInputStream(), new BufferedOutputStream(new FileOutputStream(outputFile))); } ReportDownloadResponse(RawReportDownloadResponse rawResponse); int getHttpStatus(); String getHttpResponseMessage(); @Nullable InputStream getInputStream(); String getAsString(); void saveToFile(String outputFile);  }