将 FormFile 转换为 Java.io.File

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14644333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 16:56:32  来源:igfitidea点击:

Convert FormFile to Java.io.File

javaformsfilestruts

提问by Alessandro Vasi

I have an object FormFilerecovered through a Struts Form . I have to convert Javaside in the java.io.FileHow can I do? The casting in this way by exception:

我有一个FormFile通过 Struts Form 恢复的对象。我必须Javajava.io.File我该怎么办?以这种方式铸造异常:

File myFile = (File) fileFormFile

回答by FazoM

Here, I found something you might use:

在这里,我找到了一些你可能会用到的东西:

http://www.coderanch.com/t/54902/Struts/Struts-FormFile-java-io-File

http://www.coderanch.com/t/54902/Struts/Struts-FormFile-java-io-File

回答by Jayamohan

Read the API document of FromFileclass what methods it all provides. Use getInputStream()method.

阅读FromFile类的 API 文档,它都提供了哪些方法。使用getInputStream()方法。