Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下のコードを試しました:
val stream = getClass.getResourceAsStream(path) println(stream.read())
-1 を出力します。しかし、上記のストリームから画像を読み取ろうとすると、画像が正しく表示されます。
val image = ImageIO.read(stream) println(image.getHeight())
画像の正しい高さを出力します..では、なぜストリームInputStreamが空ですか???
Liftweb 内からリソース ファイルを取得するには、「LiftRules.getResource(file)」を使用する必要があります。このようにして、*.war パッケージ内と通常のフォルダーの両方から機能します。
例: LiftRules.getResource(file).foreach(_.openStream().read())