繁体   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