
Java
文章平均质量分 53
「已注销」
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
The result of division and remainder for negative integers in Java
In Java programming, th quotient a / brounds toward 0; the remainder a % b is defined such that (a / b) * b + a % b is always equal to a. For example, -14 / 3 and 14 / -3 are both -4, but -14 % 3 is...转载 2020-03-27 22:46:59 · 280 阅读 · 0 评论 -
Java concurrency demo
import java.util.Arrays;import java.util.concurrent.locks.Condition;import java.util.concurrent.locks.Lock;import java.util.concurrent.locks.ReentrantLock;public class Bank { private final d...原创 2020-03-17 21:38:39 · 253 阅读 · 0 评论 -
【Java】粗略统计txt文本中单词的个数
import java.util.HashSet;import java.util.Scanner;import java.util.Set;public class ReadText { public static void main(String[] args) { Set<String> words = new HashSet<>()...原创 2020-03-10 22:40:46 · 730 阅读 · 0 评论 -
Spring MVC中执行操作后, 刷新页面会重复操作(已解决)
原来的代码如下:@RequestMapping("/content/update.do") public String update(Integer id, String title, String content, @RequestParam MultipartFile image, HttpServletRequest request, Htt...原创 2019-08-15 15:00:23 · 1099 阅读 · 2 评论 -
Java之获取年月日时分秒字符串
/** * 生成随机图片文件名,年月日时分秒格式 */ String getString() { Date date = new Date(System.currentTimeMillis()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String strin...原创 2019-08-15 14:32:45 · 4101 阅读 · 0 评论 -
JDBC之批量向MySQL中添加测试数据
package com.zkdx.hangul_service.test;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;public class Test { public static void main(String[] args) th...原创 2019-08-10 17:19:22 · 261 阅读 · 0 评论 -
Java生成随机文件名
/** * 生成随机图片文件名,"年月日时分秒"格式 */String randomFileName() { Date date = new Date(System.currentTimeMillis()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String fileN...原创 2019-08-19 10:51:55 · 2068 阅读 · 0 评论 -
this web application instance has been stopped already. Could not load......(已解决)
在启动项目的时候, 发生了这个错误, 查了下网上其他人的博客, 均无济于事。结果突然发现自己将实体类中的一个成员变量改了名字,而hibernate.hbm.xml文件里没有改,于是发生了上面的错误。以后不能大意了。另外,实体类中的成员变量起名时,一定要注意不能有MySQL里的保留字。最近的项目中,我写的类中有一个“固顶级别” 属性,结果将其命名为order,之后启动项目后就发生了错误,因为or...原创 2019-08-19 10:50:12 · 8805 阅读 · 0 评论 -
Spring MVC 项目获取项目根路径
在Controller层自动装配ServletContext。@AutowiredServletContext context;然后即可在Controller层的方法里获取项目的根路径。String path = context.getRealPath("/");原创 2019-08-12 11:16:53 · 2888 阅读 · 0 评论 -
Spring MVC RequestParam Annotation
In Spring MVC, the@RequestParamannotation is used to read the form data and bind it automatically to the parameter present in the provided method. So, it ignores the requirement ofHttpServletReques...原创 2019-08-12 11:30:13 · 208 阅读 · 0 评论 -
调用微信公众平台接口获取公众号菜单列表,返回JSON数据中中文乱码
发生这种情况的原因多种多样,我的项目中最后是这样解决的:在GET请求链接中加上&charset=utf-8,完美解决了问题。String url = "https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=";String tokenGetUrl = url + access_token...原创 2019-09-15 19:09:36 · 1492 阅读 · 0 评论 -
Java解析微信公众号菜单列表
因为是新手,所以写的不是很好,见谅。/** * 将微信公众号菜单列表由JSONArray格式解析为WeChatMenu对象, 并存到数据库里 * * @param wechatMenuJsonArray 微信公众号菜单列表,格式为JSONArray */ private void parseWechatMenuJsonArray(JSONArr...原创 2019-09-15 19:11:50 · 654 阅读 · 0 评论 -
Spring MVC 上传文件报错
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]: Specified class is an interface org.springframework.beans...原创 2019-09-19 20:33:54 · 308 阅读 · 0 评论 -
Java获取音频播放时长
1. 获取.amr音频文件播放时长import java.io.File;import java.io.IOException;import java.io.RandomAccessFile; public class AmrFileTimeLengthSample { public static long getAmrDuration(File file) throws IOEx...原创 2019-09-23 15:56:47 · 1746 阅读 · 0 评论 -
META-INF/MANIFEST.MF file not found in unnamed.war
AddMANIFEST.MFtoYOUR_PROJECT_NAME/web/src/main/webapp/META-INF/folder with the simple content:Manifest-Version: 1.0Or you can generate it usingIntelliJ Artifacts Configuring原创 2019-09-30 10:02:53 · 2138 阅读 · 0 评论 -
LeetCode第1题(two sum) 暴力法性能优化
最近开始刷LeetCode上的题目, 第一题two sum中, 先使用了一下暴力法, 运行了一下, 发现速度和题目给出的答案有出入, 看了一下, 发现了不同。我的代码如下:private static int[] twoSum(int[] nums, int target) { for (int i = 0; i < nums.length - 1; i++) {...原创 2019-07-22 19:58:52 · 305 阅读 · 0 评论 -
数据分页显示 之 确定总页码数(优化)
对数据进行分页显示的时候,要定义4个变量:pageNow 表示第几页,由用户决定pageSize 每页显示几条记录,由程序指定,也可以由用户定制pageCount 表示共有多少页,该变量通过计算得到rowCount 表示共有多少条记录,由查询数据库得到那么,如何确定 pageCount 呢?一般情况下,可以这样写:if (rowCoun...原创 2019-07-12 00:22:11 · 1032 阅读 · 0 评论 -
Meow-AutoClick Software Instructions
Download the SoftwareDo not unzip the archive, click the executable file and start the program.How to use:1. Click Hotkey to register hotkeys for the operations.2. Press the click hot key you ...原创 2018-10-14 17:18:54 · 333 阅读 · 0 评论 -
Java之判断一个数是否为素数
public class PrimeNumberTest { public static void main(String[] args) { long start = System.currentTimeMillis(); System.out.println(isPrimeNumber(29)); printNum(1000); ...原创 2018-11-28 22:36:57 · 3570 阅读 · 0 评论 -
网传“程序员撩妹“程序--Java实现
import java.awt.FlowLayout;import java.awt.Font;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.J...原创 2018-10-14 11:13:06 · 1576 阅读 · 0 评论 -
冒泡排序法-Java实现
public static void bubbleSort(int[] a) { int temp; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a.length - 1; j++) { if (a[j] > a[j + 1]) { temp = a[j]; a[j]...原创 2018-12-09 13:29:10 · 1861 阅读 · 0 评论 -
插入排序法-Java实现
public static void insertionSort(int[] a) { int i, j, k, temp; for (i = 1; i < a.length; i++) { temp = a[i]; j = i - 1; while (j >= 0 && temp < a[j]) { a[j + 1] = a[...原创 2018-12-09 13:30:32 · 256 阅读 · 0 评论 -
选择排序法-Java实现
public static void selectSort(int[] a) { int temp; int index; for (int i = 0; i < a.length - 1; i++) { for (int j = i + 1; j < a.length; j++) { index = i; if (a[j] < a[index...原创 2018-12-09 13:31:51 · 1224 阅读 · 0 评论 -
快速排序法-Java实现
public static void quickSort(int[] a, int left, int right) { int f, t; int rtemp, ltemp; ltemp = left; rtemp = right; f = a[(left + right) / 2]; while (ltemp < rtemp) { while (a[lte...原创 2018-12-09 13:33:08 · 338 阅读 · 0 评论 -
Shell排序法-Java实现
public static void shellSort(int[] a) { int i, j, h; int r, temp; int x = 0; for (r = a.length; r >= 1; r /= 2) for (i = r; i < a.length; i++) { temp = a[i]; j = i - r; ...原创 2018-12-09 13:34:07 · 294 阅读 · 0 评论 -
桶排序(heap sort)-Java实现
public static void heapSort(int[] a) { int i, j, k; int temp; int n = a.length; for (i = n / 2 - 1; i >= 0; i--) { while (2 * i + 1 < n) { j = 2 * i + 1; if (j + 1 < n) ...原创 2018-12-09 13:35:04 · 236 阅读 · 0 评论 -
合并排序法-Java实现
public static void mergeSort(int[] a, int low, int high) { //调用mergeSort方法时low为0, high为a.length-1 int mid = (low + high) / 2; if (low < high) { MergeSort(a, low, mid); MergeSort(a, mid +...原创 2018-12-09 13:36:03 · 311 阅读 · 0 评论 -
Java英语单词大全
Java基础常见英语词汇(70个)OO: object-oriented ,面向对象 OOP: object-oriented programming,面向对象编程JDK:Java development kit, java开发工具包 JVM:java virtual mac...原创 2018-12-22 00:19:37 · 5923 阅读 · 0 评论 -
java.lang.NumberFormatException: For input string: " 2"
解决办法(有点low哈哈哈) String id = String.format("%s", request.getParameter("productId")); int realId = Integer.parseInt(id.replaceAll(" ", "")); /* 这里用realId获取商品的id。 直接用request.getPara...原创 2019-06-09 22:43:10 · 4439 阅读 · 0 评论 -
在JSP中图片上传到服务器后无法读取(已解决)
原图片名称是中文的, 中间有一个空格.解决办法: 上传图片时, 图片用 java.uti.UUID.UUID.randomUUID()命名, 不要用原来的图片名!!!File saveFile = new File(request.getSession().getServletContext().getRealPath("\\").substring(0, 44) ...原创 2019-07-02 17:46:29 · 1080 阅读 · 0 评论 -
IntelliJ IDEA 提示"Form input without an associated label or title attribute"
在HTML中如果用了input标签,没有指定placeholder的话,IDE会提示:Form input without an associated label or title attribute解决方案:指定placeholder,如下: <input type="password" name="password" id="password" placeholder=...原创 2019-07-03 14:05:01 · 4654 阅读 · 0 评论 -
java.sql.SQLException: Column 'id' not found.
发生这种错误的原因可能有多种情况。最近在写DAO层的时候,写了一个统计数据库中商品数量的方法,结果在调用的时候,发生了这个错误。于是看了下报的错误,找到了错误的根源:java.sql.SQLException: Column 'id' not found. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLEr...原创 2019-07-15 14:30:36 · 11423 阅读 · 6 评论 -
阿拉伯数字转韩文、中文
/* * Author: @九成宫醴泉铭 * 微信公众平台:huanhuacf(幻化成风) * 微信:2992860292, QQ同号 * */import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util...原创 2018-07-21 12:12:51 · 727 阅读 · 0 评论