このサイトよりqrcode_java0.50beta10.tar.gzを取得。
public static void main(String[] args) {
try {
String testString = "123456789";
// Constructor Qrcode Object
Qrcode testQrcode = new Qrcode();
testQrcode.setQrcodeErrorCorrect('M');
testQrcode.setQrcodeEncodeMode('B');
testQrcode.setQrcodeVersion(7);
// getBytes
byte[] d = testString.getBytes("Big5");
BufferedImage bi = new BufferedImage(140, 140,
BufferedImage.TYPE_INT_RGB);
// createGraphics
Graphics2D g = bi.createGraphics();
// set background
g.setBackground(Color.WHITE);
g.clearRect(0, 0, 140, 140);
g.setColor(Color.BLACK);
if (d.length > 0 && d.length < 120) {
boolean[][] s = testQrcode.calQrcode(d);
for (int i = 0; i < s.length; i++) {
for (int j = 0; j < s.length; j++) {
if (s[j][i]) {
g.fillRect(j * 3 + 2, i * 3 + 2, 3, 3);
}
}
}
}
g.dispose();
bi.flush();
// 出力ファイル名
String FilePath = "D:\\TestQRCode.png";
File f = new File(FilePath);
// 書き出し
ImageIO.write(bi, "png", f);
} // end try
catch (Exception e) {
e.printStackTrace();
} // end catch
} // end main
出来た。世の中色々作ってくれてる人が居て助かります。