![](/img/trans.png)
[英]cannot find symbol method get/set in Gradle project Intellij Idea
[英]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.