実現したいこと
Javaで画像のフォーマットを調べて、「JPEGのときは~、PNGのときは~」と処理を分岐させたいです。
画像フォーマットは、javax.imageio.ImageReaderクラスのgetFormatNameメソッドで取得します。
質問1
ImageReader#getFormatNameメソッドは具体的に、どんな値を返すのでしょうか?
"PNG" OR "png", "JPEG" or "jpg"などが知りたいです。
公式サイトには、具体的に何が返るのか書かれていませんでした。
http://docs.oracle.com/javase/8/docs/api/javax/imageio/ImageReader.html#getFormatName--
Returns a String identifying the format of the input source.
The default implementation returns originatingProvider.getFormatNames()[0]. Implementations that may not have an originating service provider, or which desire a different naming policy should override this method.
質問2
getFormatNameメソッドの戻り値は、別クラスで定数として定義されていますか?
定義されているならば、それを参照して判定したいです。
質問3
getFormatNameメソッドを実行したところ、戻り値は
- JPEG画像は"JPEG"
- PNG画像は"png"
でした。
戻り値が大文字/小文字統一されていないのは、なぜでしょうか?

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/08/31 15:45
2016/08/31 15:53