Cornelius Roemer
Cornelius Roemer

Reputation: 8276

How to fix lint 'constructor ZipFile(File!)' is deprecated. Deprecated in Javakotlin(DEPRECATION)

In a kotlin codebase, I'm getting the following lint:

'constructor ZipFile(File!)' is deprecated. Deprecated in Javakotlin(DEPRECATION)

for the following minimal code (I've removed everything but relevant lines)

import org.apache.commons.compress.archivers.zip.ZipFile
// snip
val tempFile = File.createTempFile("test","file")
val zipFile = ZipFile(tempFile)

The docs state I should "Use ZipFile.Builder.get()" but how do I do this? I'm new to Kotlin/Java and I struggle reading the style of docs used here.

Upvotes: -1

Views: 251

Answers (1)

Cornelius Roemer
Cornelius Roemer

Reputation: 8276

I figured it out in the end, by replacing the line:

val zipFile = ZipFile(tempFile)

with

val zipFile = ZipFile.builder()
                .setFile(tempFile)
                .setUseUnicodeExtraFields(true)
                .get()

I'm not sure whether the .setUseUnicodeExtraFields(true) is a behaviour change or not - it probably doesn't matter in most cases, but this might be a source for differences in behaviour.

Upvotes: 1

Related Questions