gpt4 book ai didi

java - 保存文件的相对路径

转载 作者:行者123 更新时间:2023-12-01 14:41:09 26 4
gpt4 key购买 nike

我正在将照片从数据库复制到 Web 应用程序中路径 /WebContent/images/temp/nn.png

的文件夹中

我的目录结构是

friendit/
WebContent/
images/
temp/
nn.png

我正在将 Web 应用程序的 Controller 操作类中的图像保存到文件夹friendit/webcontent/temp/nn.png,但我收到 fileNotFound 异常

相对路径有问题!请帮我解决我应该使用什么相对路径

最佳答案

不能直接将blob类型从数据库保存到硬盘

尝试使用这个,

                Blob test=userInfo.getPicture(); //take blob form sql in test variable
InputStream x=test.getBinaryStream();
int size=x.available();




outputStream=new FileOutputStream("./WebContent/images/temp/nn.png");
byte b[]= new byte[size];
x.read(b);
outputStream.write(b);

关于java - 保存文件的相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15942923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com