package org.lxh;
import java.io.File;
import java.util.Hashtable;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
public class Ch14test {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String text = "你那么可爱,说什么都对";
int width = 300;
int height = 300;
//二维码的图片格式
String format = "jpg";
Hashtable hints = new Hashtable();
//内容所使用编码
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
BitMatrix bitMatrix = new MultiFormatWriter().encode(text,
BarcodeFormat.QR_CODE, width, height, hints);
//生成二维码
File outputFile = new File("d:"+File.separator+"new.jpg");
MatrixToImageWriter.writeToFile(bitMatrix, format, outputFile);
} 代码中String text = "你那么可爱,说什么都对"; 怎么更改才能实现 要求用户输入一段文本或者一个矩阵 然后进行二维码实现
import java.io.File;
import java.util.Hashtable;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
public class Ch14test {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String text = "你那么可爱,说什么都对";
int width = 300;
int height = 300;
//二维码的图片格式
String format = "jpg";
Hashtable hints = new Hashtable();
//内容所使用编码
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
BitMatrix bitMatrix = new MultiFormatWriter().encode(text,
BarcodeFormat.QR_CODE, width, height, hints);
//生成二维码
File outputFile = new File("d:"+File.separator+"new.jpg");
MatrixToImageWriter.writeToFile(bitMatrix, format, outputFile);
} 代码中String text = "你那么可爱,说什么都对"; 怎么更改才能实现 要求用户输入一段文本或者一个矩阵 然后进行二维码实现
String text=sc.nextLine();
sc.close();