このサイトの指示に従って、画像ファイルを Base64 文字列にエンコードしようとしています。唯一の違いは、(Java の代わりに) Groovy スクリプトを使用していることです。私のスクリプト全体はただ....
@Grapes(
@Grab(group='commons-io', module='commons-io', version='2.6')
)
import org.apache.commons.io.FileUtils
import org.apache.commons.codec.binary.Base64
byte[] fileContent = FileUtils.readFileToByteArray(new File('/Users/me/Test.jpeg'));
String encodedString = Base64.getEncoder().encodeToString(fileContent);
これを実行すると、以下の例外が発生し、理由がわかりません...
groovy.lang.MissingMethodException:
No signature of method: static org.apache.commons.codec.binary.Base64.getEncoder() is applicable for argument types: () values: []
Possible solutions: encode([B), encode(java.lang.Object)