0

basePath の場所に画像をアップロードしたいと考えています。

String path = request.getContextPath();
        String basePath = request.getScheme() + "://"
                + request.getServerName() + ":" + request.getServerPort()
                + path + "/";      
String filePath = basePath + "images_videos/";
String myFile = filePath + fileName.substring(fileName.lastIndexOf("/") + 1);
file = new File(myFile);

myFile = の上記のコード値から"http://localhost:8080/NRT/images_videos/107230452014-01-04news.png"

しかし、ファイル内の値 ="http:\localhost:8080\NRT\images_videos\107230452014-01-04news.png"

を使用してファイルを場所に書き込むときのスラッシュのこの違いのため

fi.write(file);

私は以下の例外を取得します

java.io.FileNotFoundException: http:\localhost:8080\NRT\images_videos\107230452014-01-04news.png (The filename, directory name, or volume label syntax is incorrect)

この問題を解決する方法はありますか?

情報:上記の「filePath」は、同じ場所から画像を表示するために機能します。

4

0 に答える 0