Home WeChat Applet Mini Program Development Java implementation of WeChat public account and scan code payment case

Java implementation of WeChat public account and scan code payment case

May 16, 2017 am 11:17 AM
java

WeChat payment has become an indispensable payment method in life. This article mainly introduces the official account payment and scan code payment of Java WeChat payment. Friends in need can learn more.

WeChat payment has become more and more popular, and many products have appeared with the gimmick of being able to quickly access WeChat payment. However, the convenience also makes us rely on third parties to make things. , lost the ability to think independently, this time I plan to share the WeChat payment I developed before.

1. H5 official account payment

Key points: Correctly obtain openId and unified order placementInterface, correctly handle payment result notifications, and correctly configure payment Authorization directory

The payment method of H5 is a relatively widely used method. This payment method is mainly used for the custom menu webpage in WeChat and relies on the installation on the mobile phone. WeChat client, only higher versions of WeChat support WeChat payment. Please follow my process below and pay attention to the instructions

1 Write the page for payment. Since it is for testing, it is a little simpler

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<% 
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%> 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
 <head> 
 <base href="<%=basePath%>"> 
  
 <title>微信支付样例</title> 
  
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> 
 <!-- 
 <link rel="stylesheet" type="text/css" href="styles.css"> 
 --> 
 
 </head> 
 
 <body> 
 <form action="oauthServlet" method="POST"> 
    订单号:<input type="text" name="orderNo" /> 
  <input type="submit" value="H5支付"/> 
 </form> 
 </br></br> 
  <form action="scanCodePayServlet?flag=createCode" method="POST"> 
    订单号:<input type="text" name="orderNo" /> 
  <input type="submit" value="扫码支付"/> 
 </form> 
 </body> 
</html>
Copy after login

2 Write a servlet to obtain the code through Oauth

package com.debug.weixin.servlet; 
 
import java.io.IOException; 
import java.io.PrintWriter; 
 
import javax.servlet.RequestDispatcher; 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import com.debug.weixin.util.CommonUtil; 
import com.debug.weixin.util.ServerConfig; 
public class OauthServlet extends HttpServlet { 
 
 public void doGet(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
 
  this.doPost(request, response); 
 } 
 
 public void doPost(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
 
   String orderNo=request.getParameter("orderNo"); 
   //调用微信Oauth2.0获取openid 
   String redirectURL=ServerConfig.SERVERDOMAIN+"/BasicWeixin/payServletForH5?orderNo="+orderNo; 
   String redirectURI=""; 
   try { 
    redirectURI=CommonUtil.initOpenId(redirectURL); 
   } catch (Exception e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
   } 
   //System.out.println(redirectURI); 
   //RequestDispatcher dis= request.getRequestDispatcher(redirectURI); 
   //dis.forward(request, response); 
   response.sendRedirect(redirectURI); 
 } 
}
Copy after login

3 After obtaining the code, obtain the openId through REDIRECTURI and call the unified ordering interface

package com.debug.weixin.servlet; 
 
import java.io.IOException; 
import java.io.PrintWriter; 
import java.util.SortedMap; 
import java.util.TreeMap; 
 
import javax.servlet.RequestDispatcher; 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import com.debug.weixin.pojo.WeixinOauth2Token; 
import com.debug.weixin.pojo.WeixinQRCode; 
import com.debug.weixin.util.AdvancedUtil; 
import com.debug.weixin.util.CommonUtil; 
import com.debug.weixin.util.ConfigUtil; 
import com.debug.weixin.util.PayCommonUtil; 
 
public class PayServletForH5 extends HttpServlet { 
 
  
 public void doGet(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
 
  this.doPost(request, response); 
 } 
 
 public void doPost(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
   String orderNo=request.getParameter("orderNo"); 
   String code=request.getParameter("code"); 
   
   //获取AccessToken 
   
   WeixinOauth2Token token=AdvancedUtil.getOauth2AccessToken(ConfigUtil.APPID, ConfigUtil.APP_SECRECT, code); 
   
   String openId=token.getOpenId(); 
   
   //调用微信统一支付接口 
   SortedMap<Object, Object> parameters = new TreeMap<Object, Object>(); 
  parameters.put("appid", ConfigUtil.APPID); 
 
  parameters.put("mch_id", ConfigUtil.MCH_ID); 
  parameters.put("device_info", "1000"); 
  parameters.put("body", "我的测试订单"); 
  parameters.put("nonce_str", PayCommonUtil.CreateNoncestr()); 
   
    
  parameters.put("out_trade_no", orderNo); 
  //parameters.put("total_fee", String.valueOf(total)); 
  parameters.put("total_fee", "1"); 
  parameters.put("spbill_create_ip", request.getRemoteAddr()); 
  parameters.put("notify_url", ConfigUtil.NOTIFY_URL); 
  parameters.put("trade_type", "JSAPI"); 
  parameters.put("openid", openId); 
 
  String sign = PayCommonUtil.createSign("UTF-8", parameters); 
  parameters.put("sign", sign); 
 
  String requestXML = PayCommonUtil.getRequestXml(parameters); 
 
  String result = CommonUtil.httpsRequestForStr(ConfigUtil.UNIFIED_ORDER_URL,"POST", requestXML); 
  System.out.println("----------------------------------"); 
  System.out.println(result); 
  System.out.println("----------------------------------"); 
   
  request.setAttribute("orderNo", orderNo); 
  request.setAttribute("totalPrice", "0.01"); 
  String payJSON=""; 
  try { 
   payJSON=CommonUtil.getH5PayStr(result,request); 
    
  } catch (Exception e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } 
  //System.out.println(payJSON); 
  request.setAttribute("unifiedOrder",payJSON); 
   
  RequestDispatcher dis= request.getRequestDispatcher("h5Pay.jsp"); 
  dis.forward(request, response); 
 } 
}
Copy after login

Calling the WeChat unified ordering interface requires Pay attention to the signature algorithm. Only when the signature calculation is correct can payment be made smoothly

public static String getH5PayStr(String result,HttpServletRequest request) throws Exception{ 
   
   Map<String, String> map = XMLUtil.doXMLParse(result); 
    
    
    SortedMap<Object,Object> params = new TreeMap<Object,Object>(); 
   params.put("appId", ConfigUtil.APPID); 
   params.put("timeStamp", Long.toString(new Date().getTime())); 
   params.put("nonceStr", PayCommonUtil.CreateNoncestr()); 
   params.put("package", "prepay_id="+map.get("prepay_id")); 
   params.put("signType", ConfigUtil.SIGN_TYPE); 
   String paySign = PayCommonUtil.createSign("UTF-8", params); 
   
   params.put("paySign", paySign);  //paySign的生成规则和Sign的生成规则一致 
   
   String json = JSONObject.fromObject(params).toString(); 
   
   return json; 
 }
Copy after login

4 Write the final payment interface and call up WeChat H5 payment

 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<% 
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%> 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
 <head> 
 <base href="<%=basePath%>"> 
  
 <title>微信H5支付</title> 
  
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> 
  <script type="text/javascript"> 
  
 function jsApiCall(){ 
  WeixinJSBridge.invoke( 
   &#39;getBrandWCPayRequest&#39;,<%=(String)request.getAttribute("unifiedOrder")%>, function(res){ 
    WeixinJSBridge.log(res.err_msg); 
    //alert(res.err_code+res.err_desc+res.err_msg); 
    if(res.err_msg == "get_brand_wcpay_request:ok" ) { 
     alert("恭喜你,支付成功!"); 
    }else{ 
     alert(res.err_code+res.err_desc+res.err_msg);     
    } 
   } 
  ); 
 } 
 
 function callpay(){ 
  if (typeof WeixinJSBridge == "undefined"){ 
   if( document.addEventListener ){ 
    document.addEventListener(&#39;WeixinJSBridgeReady&#39;, jsApiCall, false); 
   }else if (document.attachEvent){ 
    document.attachEvent(&#39;WeixinJSBridgeReady&#39;, jsApiCall); 
    document.attachEvent(&#39;onWeixinJSBridgeReady&#39;, jsApiCall); 
   } 
  }else{ 
   jsApiCall(); 
  } 
 } 
 </script> 
 </head> 
 
 <body> 
  <input type="button" value="支付" onclick="callpay()"/> 
 </body> 
</html>
Copy after login

5 Process WeChat payment result notification

package com.debug.weixin.servlet; 
 
import java.io.ByteArrayOutputStream; 
import java.io.IOException; 
import java.io.InputStream; 
import java.io.PrintWriter; 
import java.util.Map; 
 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import org.jdom.JDOMException; 
 
import com.debug.weixin.util.PayCommonUtil; 
import com.debug.weixin.util.XMLUtil; 
 
public class PayHandlerServlet extends HttpServlet { 
 
  
 public void doGet(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
   this.doPost(request, response); 
 } 
 
  
 public void doPost(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
 
  InputStream inStream = request.getInputStream(); 
  ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); 
  byte[] buffer = new byte[1024]; 
  int len = 0; 
  while ((len = inStream.read(buffer)) != -1) { 
   outSteam.write(buffer, 0, len); 
  } 
   
  outSteam.close(); 
  inStream.close(); 
  String result = new String(outSteam.toByteArray(),"utf-8");//获取微信调用我们notify_url的返回信息 
  Map<Object, Object> map=null; 
  try { 
   map = XMLUtil.doXMLParse(result); 
  } catch (JDOMException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } 
  for(Object keyValue : map.keySet()){ 
   System.out.println(keyValue+"="+map.get(keyValue)); 
  } 
  if (map.get("result_code").toString().equalsIgnoreCase("SUCCESS")) { 
    
   //对订单进行业务操作 
   System.out.println("-------------OK"); 
   response.getWriter().write(PayCommonUtil.setXML("SUCCESS", "")); //告诉微信服务器,我收到信息了,不要在调用回调action了 
    
  } 
 } 
}
Copy after login

For A lot of the above code refers to blog.csdn.net/u011160656/article/details/41759195, so this part of the code will not be posted. If you need it, just read this blog.

2 WeChat scan code payment (Mode 1)

Key points: long link to short link interface must be called, and the scan code must be configured correctly Code payment callback URL

1 Generate WeChat payment QR code based on the order number

The following are several methods for generating QR codes:

package com.debug.weixin.util; 
import com.google.zxing.common.BitMatrix; 
 
 import javax.imageio.ImageIO; 
 import java.io.File; 
 import java.io.OutputStream; 
 import java.io.IOException; 
 import java.awt.image.BufferedImage; 
 
 
 public final class MatrixToImageWriter { 
 
 private static final int BLACK = 0xFF000000; 
 private static final int WHITE = 0xFFFFFFFF; 
 
 private MatrixToImageWriter() {} 
 
  
 public static BufferedImage toBufferedImage(BitMatrix matrix) { 
  int width = matrix.getWidth(); 
  int height = matrix.getHeight(); 
  BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 
  for (int x = 0; x < width; x++) { 
  for (int y = 0; y < height; y++) { 
   image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE); 
  } 
  } 
  return image; 
 } 
  
 public static void writeToFile(BitMatrix matrix, String format, File file) 
  throws IOException { 
  BufferedImage image = toBufferedImage(matrix); 
  if (!ImageIO.write(image, format, file)) { 
  throw new IOException("Could not write an image of format " + format + " to " + file); 
  } 
 } 
 
  
 public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) 
  throws IOException { 
  BufferedImage image = toBufferedImage(matrix); 
  if (!ImageIO.write(image, format, stream)) { 
  throw new IOException("Could not write an image of format " + format); 
  } 
 } 
 
 }
Copy after login

This is considered a tool class, and One method is to display the QR code on the interface. CreateQRCode mainly uses code blocks:

 public static void createCodeStream(String text,HttpServletResponse response) throws Exception{ 
  
  // response.setContentType("image/jpeg"); 
  ServletOutputStream sos = response.getOutputStream(); 
 
  int width = 500; 
  int height = 500; 
  //二维码的图片格式 
  String format = "jpg"; 
  MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); 
  Map hints = new HashMap(); 
  //内容所使用编码 
  hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); 
  BitMatrix bitMatrix = multiFormatWriter.encode(text, BarcodeFormat.QR_CODE, width, height, hints); 
  
  
  //生成二维码 
  
  MatrixToImageWriter.writeToStream(bitMatrix, format,sos); 
  
  sos.close(); 
  
  
 }
Copy after login

2 Convert the long link to the short link to generate the QR code, write the scan code payment callback method and call the unified order Interface

 package com.debug.weixin.servlet; 
 
import java.io.ByteArrayOutputStream; 
import java.io.IOException; 
import java.io.InputStream; 
import java.io.PrintWriter; 
import java.util.Date; 
import java.util.Map; 
import java.util.SortedMap; 
import java.util.TreeMap; 
 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
 
import org.jdom.JDOMException; 
 
import com.debug.weixin.util.CommonUtil; 
import com.debug.weixin.util.ConfigUtil; 
import com.debug.weixin.util.CreateQRCode; 
import com.debug.weixin.util.PayCommonUtil; 
import com.debug.weixin.util.XMLUtil; 
import com.mongodb.DBObject; 
 
public class ScanCodePayServlet extends HttpServlet { 
 
  
 public void doGet(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
  this.doPost(request, response); 
   
 } 
 
  
 public void doPost(HttpServletRequest request, HttpServletResponse response) 
   throws ServletException, IOException { 
   
  String flag=request.getParameter("flag"); 
  if("createCode".equals(flag)){ 
   createPayCode(request,response); 
  }else{ 
   try { 
    wxScanCodeHandler(request,response); 
   } catch (Exception e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
   } 
  } 
   
   
 } 
  
 public void createPayCode(HttpServletRequest request,HttpServletResponse response){ 
   
  String orderNo=request.getParameter("orderNo"); 
   
  SortedMap<Object,Object> paras = new TreeMap<Object,Object>(); 
  paras.put("appid", ConfigUtil.APPID); 
  paras.put("mch_id", ConfigUtil.MCH_ID); 
  paras.put("time_stamp", Long.toString(new Date().getTime())); 
  paras.put("nonce_str", PayCommonUtil.CreateNoncestr()); 
  paras.put("product_id", orderNo);//商品号要唯一 
  String sign = PayCommonUtil.createSign("UTF-8", paras); 
  paras.put("sign", sign); 
   
  String url = "weixin://wxpay/bizpayurl?sign=SIGN&appid=APPID&mch_id=MCHID&product_id=PRODUCTID&time_stamp=TIMESTAMP&nonce_str=NOCESTR"; 
  String nativeUrl = url.replace("SIGN", sign).replace("APPID", ConfigUtil.APPID).replace("MCHID", ConfigUtil.MCH_ID).replace("PRODUCTID", (String)paras.get("product_id")).replace("TIMESTAMP", (String)paras.get("time_stamp")).replace("NOCESTR", (String)paras.get("nonce_str")); 
   
 
 
   SortedMap<Object,Object> parameters = new TreeMap<Object,Object>(); 
   parameters.put("appid", ConfigUtil.APPID); 
   parameters.put("mch_id", ConfigUtil.MCH_ID); 
   parameters.put("nonce_str", PayCommonUtil.CreateNoncestr()); 
   parameters.put("long_url", CommonUtil.urlEncodeUTF8(nativeUrl)); 
   String sign2 = PayCommonUtil.createSign("UTF-8", parameters); 
   parameters.put("sign", sign2); 
   String requestXML = PayCommonUtil.getRequestXml(parameters); 
   String result =CommonUtil.httpsRequestForStr(ConfigUtil.SHORT_URL, "POST", requestXML); 
   
   Map<String, String> map=null; 
  try { 
   map = XMLUtil.doXMLParse(result); 
  } catch (JDOMException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } catch (IOException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } 
   String returnCode = map.get("return_code"); 
   String resultCode = map.get("result_code"); 
   
   if(returnCode.equalsIgnoreCase("SUCCESS")&&resultCode.equalsIgnoreCase("SUCCESS")){ 
    
    String shortUrl = map.get("short_url"); 
    //TODO 拿到shortUrl,写代码生成二维码 
    System.out.println("shortUrl="+shortUrl); 
    try { 
    CreateQRCode.createCodeStream(shortUrl,response); 
    } catch (Exception e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
    } 
  } 
 } 
  
  
 public void wxScanCodeHandler(HttpServletRequest request,HttpServletResponse response) throws Exception { 
  InputStream inStream = request.getInputStream(); 
  ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); 
  byte[] buffer = new byte[1024]; 
  int len = 0; 
  while ((len = inStream.read(buffer)) != -1) { 
   outSteam.write(buffer, 0, len); 
  } 
   
  outSteam.close(); 
  inStream.close(); 
  String result = new String(outSteam.toByteArray(),"utf-8");//获取微信调用我们notify_url的返回信息 
  Map<Object, Object> map=null; 
  try { 
   map = XMLUtil.doXMLParse(result); 
  } catch (JDOMException e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } 
  for(Object keyValue : map.keySet()){ 
   System.out.println(keyValue+"="+map.get(keyValue)); 
  } 
  String orderNo=map.get("product_id").toString(); 
   
  //接收到请求参数后调用统一下单接口 
  SortedMap<Object, Object> parameters = new TreeMap<Object, Object>(); 
  parameters.put("appid", ConfigUtil.APPID); 
 
  parameters.put("mch_id", ConfigUtil.MCH_ID); 
  parameters.put("device_info", "1000"); 
  parameters.put("body", "测试扫码支付订单"); 
  parameters.put("nonce_str", PayCommonUtil.CreateNoncestr()); 
   
    
  parameters.put("out_trade_no", map.get("product_id")); 
  //parameters.put("total_fee", String.valueOf(totalPrice)); 
  parameters.put("total_fee", "1"); 
  parameters.put("spbill_create_ip", request.getRemoteAddr()); 
  parameters.put("notify_url", ConfigUtil.NOTIFY_URL); 
  parameters.put("trade_type", "NATIVE"); 
  parameters.put("openid", map.get("openid")); 
 
  String sign = PayCommonUtil.createSign("UTF-8", parameters); 
  
  parameters.put("sign", sign); 
 
  String requestXML = PayCommonUtil.getRequestXml(parameters); 
 
  String result2 = CommonUtil.httpsRequestForStr(ConfigUtil.UNIFIED_ORDER_URL,"POST", requestXML); 
   
  System.out.println("-----------------------------统一下单结果---------------------------"); 
  System.out.println(result2); 
  Map<String, String> mm=null; 
  try { 
   mm=getH5PayMap(result2,request); 
  } catch (Exception e) { 
   // TODO Auto-generated catch block 
   e.printStackTrace(); 
  } 
  //String prepayId=getPrepayId(result2,request); 
  //String returnNoneStr=getReturnNoneStr(result2,request); 
  String prepayId=mm.get("prepay_id"); 
  String returnNoneStr=mm.get("nonce_str");; 
  SortedMap<Object, Object> lastSign = new TreeMap<Object, Object>(); 
  lastSign.put("return_code", "SUCCESS"); 
  lastSign.put("appid", ConfigUtil.APPID); 
  lastSign.put("mch_id", ConfigUtil.MCH_ID); 
  lastSign.put("nonce_str", returnNoneStr); 
  lastSign.put("prepay_id", prepayId); 
  lastSign.put("result_code", "SUCCESS"); 
  lastSign.put("key", ConfigUtil.API_KEY); 
   
   
  String lastSignpara = PayCommonUtil.createSign("UTF-8", lastSign); 
   
   
  StringBuffer buf=new StringBuffer(); 
  buf.append("<xml>"); 
  buf.append("<return_code>SUCCESS</return_code>"); 
  buf.append("<appid>"+ConfigUtil.APPID+"</appid>"); 
  buf.append("<mch_id>"+ConfigUtil.MCH_ID+"</mch_id>"); 
  buf.append("<nonce_str>"+returnNoneStr+"</nonce_str>"); 
  buf.append("<prepay_id>"+prepayId+"</prepay_id>"); 
  buf.append("<result_code>SUCCESS</result_code>"); 
  buf.append("<sign>"+lastSignpara+"</sign>"); 
  buf.append("</xml>"); 
   
  response.getWriter().print(buf.toString()); 
 } 
  
 public Map<String, String> getH5PayMap(String result,HttpServletRequest request) throws Exception{ 
   
   Map<String, String> map = XMLUtil.doXMLParse(result); 
   return map; 
 } 
 
}
Copy after login

Finally, let’s take a look at the WeChat configuration of official account payment and scan code payment:

[Related recommendations]

1. Special recommendation: "php Programmer Toolbox" V0.1 version download

2. WeChat applet complete source code download

3. WeChat applet demo: imitating NetEase Cloud Music

The above is the detailed content of Java implementation of WeChat public account and scan code payment case. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Square Root in Java Square Root in Java Aug 30, 2024 pm 04:26 PM

Guide to Square Root in Java. Here we discuss how Square Root works in Java with example and its code implementation respectively.

Perfect Number in Java Perfect Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Perfect Number in Java. Here we discuss the Definition, How to check Perfect number in Java?, examples with code implementation.

Random Number Generator in Java Random Number Generator in Java Aug 30, 2024 pm 04:27 PM

Guide to Random Number Generator in Java. Here we discuss Functions in Java with examples and two different Generators with ther examples.

Weka in Java Weka in Java Aug 30, 2024 pm 04:28 PM

Guide to Weka in Java. Here we discuss the Introduction, how to use weka java, the type of platform, and advantages with examples.

Smith Number in Java Smith Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

Java Spring Interview Questions Java Spring Interview Questions Aug 30, 2024 pm 04:29 PM

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

TimeStamp to Date in Java TimeStamp to Date in Java Aug 30, 2024 pm 04:28 PM

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

See all articles