真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

郵箱

package com.nine.util;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;

import com.nine.util.EmailThread;
import com.google.zxing.*;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import sun.misc.BASE64Encoder;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.UUID;

import static com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage;
import static com.google.zxing.client.j2se.MatrixToImageWriter.writeToFile;

public class TwoDimensionCode
{
public static class QRCodeTest {

/**
* @throws WriterException
* @throws IOException
*/
public void testEncodeToEmail(String content, int width, int height, String name, String format, String title, String address) throws WriterException, IOException {
String filePath = "D://";
String fileName = name + ".png";

Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);// 生成矩陣
Path path = FileSystems.getDefault().getPath(filePath, fileName);
MatrixToImageWriter.writeToPath(bitMatrix, "png", path);// 輸出圖像

Thread thread = new Thread(new EmailThread(content, title, address, filePath + fileName, fileName));
thread.run();
}
<<<<<<< HEAD
=======

public String returnQRCodePath(String content, int width, int height, String format, HttpServletRequest request) throws Exception{
String filePath = request.getSession().getServletContext().getRealPath("")+"/resources/img/";
String uuid= UUID.randomUUID().toString().replaceAll("-","");
String fileName = uuid + ".png";

Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);// 生成矩陣
Path path = FileSystems.getDefault().getPath(filePath, fileName);
MatrixToImageWriter.writeToPath(bitMatrix, "png", path);// 輸出圖像

String QRCodePath="/resources/img/"+fileName;
return QRCodePath;
}

>>>>>>> 9bfabb81561d39881f23480cbaa604741bf9f87f
/**
* 生成圖像
*
* @throws WriterException
* @throws IOException
*/
public static BitMatrix testEncode(String filePath,String content ) {

int width = 200; // 圖像寬度
int height = 200; // 圖像高度
String format = "png";// 圖像類(lèi)型
BitMatrix bitMatrix =null;
try {
Map hints = new HashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
// 生成矩陣
bitMatrix = new MultiFormatWriter().encode(content,
BarcodeFormat.QR_CODE, width, height, hints);
if(filePath!=null){
Path path = FileSystems.getDefault().getPath(filePath);
MatrixToImageWriter.writeToPath(bitMatrix, format, path);// 輸出圖像
System.out.println("輸出成功.");
}
} catch (WriterException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return bitMatrix;
}

/**
* 解析圖像
*/
//解析二維碼
//fileName:被解析的二維碼內(nèi)容
public void readQRcode(String fileName) {
try {
MultiFormatReader formatReader = new MultiFormatReader();
File file = new File("d:/" + fileName + ".png");
BufferedImage image = ImageIO.read(file);//讀取文件,識(shí)別成一個(gè)圖片
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(image)));
//二維碼的參數(shù)
HashMap hints = new HashMap<>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
Result result = formatReader.decode(binaryBitmap, hints);

System.out.println("解析二維碼的結(jié)果:" + result.toString());
System.out.println("二維碼的格式:" + result.getBarcodeFormat());
System.out.println("二維碼的內(nèi)容:" + result.getText());
} catch (NotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

public static String generalQRCode(String url) {
Hashtable hints = new Hashtable();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
String binary = null;

try {
BitMatrix bitMatrix = new MultiFormatWriter().encode(
url, BarcodeFormat.QR_CODE, 200, 200, hints);

// 實(shí)現(xiàn)一: 輸出圖片到指定目錄
// File outputFile = new File("d://1.jpg");
// MatrixToImageWriter.writeToFile(bitMatrix, "png", outputFile);

// 實(shí)現(xiàn)二:生成二維碼圖片并將圖片轉(zhuǎn)為二進(jìn)制傳遞給前臺(tái)
// 1、讀取文件轉(zhuǎn)換為字節(jié)數(shù)組
ByteArrayOutputStream out = new ByteArrayOutputStream();
BufferedImage image = toBufferedImage(bitMatrix);
////
ImageIO.write(image, "png", out);
byte[] bytes = out.toByteArray();

// 2、將字節(jié)數(shù)組轉(zhuǎn)為二進(jìn)制
BASE64Encoder encoder = new BASE64Encoder();
binary = encoder.encodeBuffer(bytes).trim();

} catch (Exception e) {
e.printStackTrace();
}

return binary;
}

/* public static void main(String[] arg0) throws IOException, WriterException {
QRCodeTest qrCodeTest = new QRCodeTest();
qrCodeTest.testEncodeToEmail("歐巴",300,300,"piao","png","接旨","2960882886@qq.com");
*//* qrCodeTest.testEncode("as",200,200,"bbb","png");
qrCodeTest.testEncode("",200,200,"deping","png");
qrCodeTest.readQRcode("ok");
*//*
String a = generalQRCode("D://c.png");

}*/

}

創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿(mǎn)足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的克井網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

package com.nine.util;

import java.util.Random;

public class RandomUtil {

//生成隨機(jī)數(shù)字和字母
public static String getStringRandom() {
String val = "";
Random random = new Random();

//參數(shù)length,表示生成幾位隨機(jī)數(shù)
for(int i = 0; i < 4; i++) {

String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
//輸出字母還是數(shù)字
if( "char".equalsIgnoreCase(charOrNum) ) {
//輸出是大寫(xiě)字母還是小寫(xiě)字母
int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
val += (char)(random.nextInt(26) + temp);
} else if( "num".equalsIgnoreCase(charOrNum) ) {
val += String.valueOf(random.nextInt(10));
}
}
return val;
}
}

package com.nine.pojo;

public class MyEmail {
private static MyEmail email;
private String host = "smtp.163.com"; // 發(fā)送方郵箱host
private String from = "17600246280@163.com"; // 發(fā)送方郵箱
private String user = "17600246280"; // 發(fā)送方郵箱賬號(hào)
private String pwd = "ovel1314.21"; // 發(fā)送方郵箱密碼

public static MyEmail getEmail(){
if(email!=null){
return email;
}else{
email = new MyEmail();
return email;
}
}
public String getFrom() {
return from;
}

public String getUser() {
return user;
}

public String getPwd() {
return pwd;
}

public String getHost() {
return host;
}
}

package com.nine.service;

public interface ISendEmailService {
/**
* 寫(xiě)一個(gè)發(fā)送郵件的方法
* @param content
* @param title
* @param address
* @param affix
* @param affixName
*/
void send(String content, String title, String address, String affix, String affixName);
}

package com.nine.service.impl;

import com.nine.pojo.MyEmail;
import com.nine.service.ISendEmailService;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class SendEmailServiceImpl implements ISendEmailService {

@Override
public void send(String content, String title, String address, String affix, String affixName) {
MyEmail myEmail = MyEmail.getEmail();
String host = myEmail.getHost();
String user = myEmail.getUser();
String pwd = myEmail.getPwd();
String from = myEmail.getFrom();

Properties props = new Properties();

// 設(shè)置發(fā)送郵件的郵件服務(wù)器的屬性(這里使用網(wǎng)易的smtp服務(wù)器) -->需要修改
props.put("mail.smtp.host", host);
// 需要經(jīng)過(guò)授權(quán),也就是有戶(hù)名和密碼的校驗(yàn),這樣才能通過(guò)驗(yàn)證(一定要有這一條)
props.put("mail.smtp.auth", "true");

// 用剛剛設(shè)置好的props對(duì)象構(gòu)建一個(gè)session
Session session = Session.getDefaultInstance(props);

// 有了這句便可以在發(fā)送郵件的過(guò)程中在console處顯示過(guò)程信息,供調(diào)試使
// 用(你可以在控制臺(tái)(console)上看到發(fā)送郵件的過(guò)程)
session.setDebug(true);

// 用session為參數(shù)定義消息對(duì)象
MimeMessage message = new MimeMessage(session);
try {
// 加載發(fā)件人地址 -->需要修改
message.setFrom(new InternetAddress(from));
// 加載收件人地址 -->需要修改
message.addRecipients(Message.RecipientType.TO, address);
List list = new ArrayList();//不能使用string類(lèi)型的類(lèi)型,這樣只能發(fā)送一個(gè)收件人
String []median=address.split(",");//對(duì)輸入的多個(gè)郵件進(jìn)行逗號(hào)分割
for(int i=0;ilist.add(new InternetAddress(median[i]));
}
InternetAddress[] addresses =(InternetAddress[])list.toArray(new InternetAddress[list.size()]);
message.addRecipients(Message.RecipientType.TO, addresses);
// 加載標(biāo)題 --->也需要修改
message.setSubject(title);

// 向multipart對(duì)象中添加郵件的各個(gè)部分內(nèi)容,包括文本內(nèi)容和附件
Multipart multipart = new MimeMultipart();

// 設(shè)置郵件的文本內(nèi)容
BodyPart contentPart = new MimeBodyPart();
//需要修改的地方 寫(xiě)的內(nèi)容
contentPart.setText(content);

multipart.addBodyPart(contentPart);
// 添加附件
if(affix != null && !"".equals(affix))
{
BodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(affix);
// 添加附件的內(nèi)容
messageBodyPart.setDataHandler(new DataHandler(source));
// 添加附件的標(biāo)題
// 這里很重要,通過(guò)下面的Base64編碼的轉(zhuǎn)換可以保證你的中文附件標(biāo)題名在發(fā)送時(shí)不會(huì)變成亂碼
sun.misc.BASE64Encoder enc = new sun.misc.BASE64Encoder();
messageBodyPart.setFileName("=?GBK?B?"+ enc.encode(affixName.getBytes()) + "?=");
multipart.addBodyPart(messageBodyPart);
}

// 將multipart對(duì)象放到message中
message.setContent(multipart);
// 保存郵件
message.saveChanges();
// 發(fā)送郵件
Transport transport = session.getTransport("smtp");
// 連接服務(wù)器的郵箱
transport.connect(host, user, pwd);
// 把郵件發(fā)送出去
transport.sendMessage(message, message.getAllRecipients());
transport.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

from=kojikazama@163.com
user=kojikazama
pwd=zhuhaojie9015
host=smpt.163.com



管理員注冊(cè)













郵箱
真實(shí)姓名
密碼
頭像
驗(yàn)證碼



//發(fā)送二維碼驗(yàn)證
@RequestMapping(value = "sendCode",method = RequestMethod.GET)
@ResponseBody
public Map sendQRCode(String email) throws IOException, WriterException {
String title="XXX資訊后臺(tái)管理系統(tǒng)";
String code= RandomUtil.getStringRandom();
String content="歡迎注冊(cè)本平臺(tái),你的驗(yàn)證碼是:"+code;
TwoDimensionCode.QRCodeTest qrCodeTest = new TwoDimensionCode.QRCodeTest();
qrCodeTest.testEncodeToEmail(content,300,300,"piao","png",title,email);
Map map=new HashMap<>();
map.put("checkCode",",code);
return map;

}


標(biāo)題名稱(chēng):郵箱
鏈接地址:http://weahome.cn/article/cggidd.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話(huà)咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部