https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

marko ziza

04/11/2022, 4:47 PM
Hello, I don't know how to call this Java code from Kotlin:
Copy code
public static Document parse(File file, @Nullable String charsetName) throws IOException {
        return DataUtil.load(file, charsetName, file.getAbsolutePath());
    }
when I call this code from Kotlin,
Copy code
val document = Jsoup.parse(inputHTML, null )
I get
Copy code
Kotlin: Null can not be a value of a non-null type String
How can I call this with Java type null, since parameter is @Nullable and therefore Null should be accepted.
e

ephemient

04/11/2022, 5:01 PM
what is the type of
inputHTML
? Jsoup has multiple overloads and there's a non-nullable
Jsoup.parse(String, String)
method
n

nkiesel

04/11/2022, 5:01 PM
What is the type of your
inputHTML
? JSoup also has a `public static Document parse​(String html, Parser parser)`method
m

marko ziza

04/11/2022, 6:49 PM
It is java.io.File
4 Views