熊出没_007 2016-12-28 10:13 采纳率: 0%
浏览 888

Java写的二维码 为什么Path不能导包?

package com.xaccp.test;

import java.io.File;
import java.util.HashMap;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

public class Test {

public static void main(String[] args) {
    int width = 300;
    int height = 300;
    String format = "png";
    String content = "王豪";

    HashMap hints = new HashMap();
    hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
    hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
    hints.put(EncodeHintType.MARGIN, 2);

    try {
        BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height,hints);

        Path file = new File("E:/");
        MatrixToImageWriter.writeToPath(bitMatrix, format, content,file);
    } catch (WriterException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}

  • 写回答

2条回答 默认 最新

  • threenewbee 2016-12-28 15:26
    关注

    Path file = new File("E:/"); 路径是全角的冒号

    评论

报告相同问题?

悬赏问题

  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决