Source:
<code>private boolean downLoadAndVerifySegmentContent(String tableNameWithType, IndexSegment segment) { String segmentPath = "/tables/" + tableNameWithType + "/segments/" + segment.getSegmentName(); Response response = _webTarget.path(segmentPath).request().get(Response.class); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); File segmentFile = response.readEntity(File.class); File tempMetadataDir = new File(FileUtils.getTempDirectory(), "segment_metadata"); try ( InputStream metadataPropertiesInputStream = TarGzCompressionUtils .unTarOneFile(new FileInputStream(segmentFile), V1Constants.MetadataKeys.METADATA_FILE_NAME); InputStream creationMetaInputStream = TarGzCompressionUtils .unTarOneFile(new FileInputStream(segmentFile), V1Constants.SEGMENT_CREATION_META)) { Preconditions .checkState(tempMetadataDir.mkdirs(), "Failed to create directory: %s", tempMetadataDir.getAbsolutePath()); Preconditions.checkNotNull(metadataPropertiesInputStream, "%s does not exist", V1Constants.MetadataKeys.METADATA_FILE_NAME); <START> java.nio.file.Path metadataPropertiesPath = FileSystems.getDefault() <END> .getPath(tempMetadataDir.getAbsolutePath(), V1Constants.MetadataKeys.METADATA_FILE_NAME); Files.copy(metadataPropertiesInputStream, metadataPropertiesPath); Preconditions.checkNotNull(creationMetaInputStream, "%s does not exist", V1Constants.SEGMENT_CREATION_META); java.nio.file.Path creationMetaPath = FileSystems.getDefault().getPath(tempMetadataDir.getAbsolutePath(), V1Constants.SEGMENT_CREATION_META); Files.copy(creationMetaInputStream, creationMetaPath); SegmentMetadataImpl metadata = new SegmentMetadataImpl(tempMetadataDir); Assert.assertEquals(tableNameWithType, metadata.getTableName()); return true; } catch (Exception e) { return false; } finally { FileUtils.deleteQuietly(tempMetadataDir); } }</code><technical_language>import java.nio.file.Path;</technical_language>

Target:
private boolean downLoadAndVerifySegmentContent(String tableNameWithType, IndexSegment segment) { String segmentPath = "/segments/" + tableNameWithType + "/" + segment.getSegmentName(); Response response = _webTarget.path(segmentPath).request().get(Response.class); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); File segmentFile = response.readEntity(File.class); File tempMetadataDir = new File(FileUtils.getTempDirectory(), "segment_metadata"); try ( InputStream metadataPropertiesInputStream = TarGzCompressionUtils .unTarOneFile(new FileInputStream(segmentFile), V1Constants.MetadataKeys.METADATA_FILE_NAME); InputStream creationMetaInputStream = TarGzCompressionUtils .unTarOneFile(new FileInputStream(segmentFile), V1Constants.SEGMENT_CREATION_META)) { Preconditions .checkState(tempMetadataDir.mkdirs(), "Failed to create directory: %s", tempMetadataDir.getAbsolutePath()); Preconditions.checkNotNull(metadataPropertiesInputStream, "%s does not exist", V1Constants.MetadataKeys.METADATA_FILE_NAME); Path metadataPropertiesPath = FileSystems.getDefault() .getPath(tempMetadataDir.getAbsolutePath(), V1Constants.MetadataKeys.METADATA_FILE_NAME); Files.copy(metadataPropertiesInputStream, metadataPropertiesPath); Preconditions.checkNotNull(creationMetaInputStream, "%s does not exist", V1Constants.SEGMENT_CREATION_META); Path creationMetaPath = FileSystems.getDefault().getPath(tempMetadataDir.getAbsolutePath(), V1Constants.SEGMENT_CREATION_META); Files.copy(creationMetaInputStream, creationMetaPath); SegmentMetadataImpl metadata = new SegmentMetadataImpl(tempMetadataDir); Assert.assertEquals(tableNameWithType, metadata.getTableName()); return true; } catch (Exception e) { LOGGER.error("Failure in segment extraction and verification:", e); return false; } finally { FileUtils.deleteQuietly(tempMetadataDir); } }