簡體   English   中英

file.getName() 找不到方法 getName() 的符號(使用 Gradle 和 Javalin)

[英]file.getName() cannot find symbol for method getName() (using Gradle and Javalin)

當我嘗試運行此代碼時:

FileUtils.copyInputStreamToFile(file.getContent(), new File("upload/" + file.getName()));

我收到此錯誤:

error: cannot find symbol
symbol:   method getName()
location: variable file of type UploadedFile

我已經導入了這些:

import java.io.*;
import org.apache.commons.io.FileUtils;

我正在使用 Gradle 並且我已經添加到 build.gradle.kts 中的依賴項中:

 implementation(group= "commons-io", name= "commons-io", version= "2.5")

因此 build.gradle.kts 文件構建正確。

我還應該導入什么? 我錯過了什么?

Javalin 的UploadedFile沒有名為name的屬性。 但是,它有filename ,所以這可能有效(未經測試):

FileUtils.copyInputStreamToFile(file.getContent(), new File("upload/" + file.getFilename()));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM