java
fabbymee
fabbymee.com
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
android 中设置时区为北京时间
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");TimeZone pst = TimeZone.getTimeZone("Etc/GMT-8");Date curDate = new Date(System.currentTimeMillis());formatter.setTimeZone(pst);String curTime = formatter.format(curDate).replace.原创 2021-06-02 14:57:21 · 1431 阅读 · 0 评论 -
用ListView显示ImageView和TextView
类CustomCountryListpackage com.clx.androidtest0526;import android.app.Activity;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.ImageView;import and原创 2021-05-26 14:54:19 · 551 阅读 · 0 评论 -
java servlet通过url下载文件
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub// response.getWriter().append("Served at: ").append(request.getContextPath()); response.setC..原创 2020-06-23 15:39:46 · 404 阅读 · 0 评论 -
java 计算自定义底数的对数
To calculate a logarithm with custom base in Java, we use the following identity: 1 2 3 4 5 6 7 8 9 @Test public void givenCustomLog_shouldReturnValidResults() { assertEquals(customLog(2, 256...转载 2020-06-16 18:16:52 · 1174 阅读 · 0 评论 -
java mysql 查询的tinyint值显示为true,false
java mysql 查询的tinyint值显示为true,false转载 2020-06-10 13:09:06 · 1184 阅读 · 0 评论 -
mysql 密码包含特殊字符时,java无法连接Access denied for user
mysql 密码包含特殊字符时,java无法连接Access denied for user 'username'@'localhost' (using password: YES)原创 2020-06-09 16:00:36 · 1846 阅读 · 0 评论 -
java web项目中如何存放和读取资源配置文件
It's your choice. There are basically three ways in a Java web application archive (WAR):1. Put it in classpathSo that you can load it byClassLoader#getResourceAsStream()with a classpath-relative path:ClassLoader classLoader = Thread.currentThread..转载 2020-06-03 13:37:58 · 479 阅读 · 0 评论 -
严重: 子容器启动失败java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: 无法启动组件
eclipse eemvc spring严重: 子容器启动失败java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: 无法启动组件[org.apache.catalina.webresources.StandardRoot@63f8276e] at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)...原创 2020-06-02 18:37:54 · 4349 阅读 · 2 评论 -
eclipse 经常加载http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 无法访问
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http:...原创 2020-05-31 14:22:05 · 3393 阅读 · 0 评论 -
intellij idea 运行时报错the output path is not specified for module
intellij idea 运行时报错:the output path is not specified for module Specify the output path in the Project Structure dialog其实就是没有配置编译路径,ctrl+alrt+shift+s打开配置界面3.设置项目编译目录3.1添加目录我们在刚才创建的项目中添加几个目录...转载 2020-05-07 13:42:07 · 48581 阅读 · 2 评论 -
java使用ssh的方式连接到mysql
using SSH tunnel in Java throughjsch, a Java an implementation of SSH2you have to have an SSH account on the remote host, and for the database example, a database account with a"connect"permi...原创 2019-12-13 18:20:15 · 1089 阅读 · 0 评论 -
使用jsch以ssh的方式访问mysql ,如果提示PortForwardingL: local port 127.0.0.1:1119 cannot be bound.,则每次运行程序前先把原来的程
使用jsch以ssh的方式访问mysql ,如果提示PortForwardingL: local port 127.0.0.1:1119 cannot be bound.,则每次运行程序前先把原来的程序暂停JSchException**:PortForwardingL: local port 127.0.0.1:1119 cannot be bound.也可以在获取异常后} f...原创 2019-12-13 14:41:21 · 2124 阅读 · 0 评论 -
java拷贝/复制文件到其他文件夹中
java拷贝/复制文件到其他文件夹中,如果文件夹中已经有同名的文件了,则会覆盖此文件 /** * @param src * @param destDir * @param newFileName * @return * 会覆盖同名文件 */ public long copyFile(String src, String destDir, String newFil转载 2015-08-28 15:44:24 · 767 阅读 · 0 评论 -
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValue
Add commons-collections4-x.x.jar file in your build path and try it again. It will work.You can download it from https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.0翻译 2018-10-31 11:51:06 · 311 阅读 · 0 评论 -
java 10 maven报错 [ERROR] 不再支持源选项 1.5。请使用 1.6 或更高版本。
<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version><configuration>原创 2018-10-29 18:17:43 · 1396 阅读 · 0 评论 -
MAVEN项目标准目录结构
src -main –bin 脚本库 –java java源代码文件 –resources 资源库,会自动复制到classes目录里 –filters 资源过滤文件 –assembly 组件的描述配置(如何打包) –config 配置文件 –webapp web应用的目录。WEB-INF、css、js等 ...原创 2018-12-09 15:32:52 · 2347 阅读 · 0 评论 -
JDBC为什么要使用PreparedStatement而不是Statement
PreparedStatement是用来执行SQL查询语句的API之一,Java提供了 Statement、PreparedStatement 和 CallableStatement三种方式来执行查询语句,其中 Statement 用于通用查询, PreparedStatement 用于执行参数化查询,而 CallableStatement则是用于存储过程。同时PreparedStatement还...转载 2018-12-25 11:47:15 · 298 阅读 · 0 评论 -
selenium 使用katalon Recorder导出java webdriver testng 简单示例
package com.example.tests;import java.util.regex.Pattern;import java.util.concurrent.TimeUnit;import org.testng.annotations.*;import static org.testng.Assert.*;import org.openqa.selenium.*;imp...原创 2019-01-25 11:47:04 · 914 阅读 · 0 评论 -
selenium 获取直接的子节点
Get all immediate children and nothing deeper <html> <body> <div> </div> <span> <table> </table> </span>原创 2019-01-29 11:31:26 · 7656 阅读 · 0 评论 -
java pattern.matcher() vs pattern.matches()
pattern.matcher(String s) returns a Matcher that can find patterns in the String s. pattern.matches(String str) tests, if the entire String (str) matches the pattern.In brief (just to remember the...翻译 2019-02-13 15:30:26 · 1038 阅读 · 0 评论 -
读取的问题内容有中文,java file not found exception,
读取的问题内容有中文,java file not found exception,文件类型encoding 应该为utf-8无bom原创 2019-05-17 10:40:31 · 551 阅读 · 0 评论 -
JSch: UnknownHostKey exception
com.jcraft.jsch.JSchException: UnknownHostKey: localhost. RSA key fingerprint is 50:db:75:ba:11:2f:43:c9:ab:14:40:6d:7f:a1:ee:e3Jsch优先使用RSA key type所以在本地终端要用ssh-o HostKeyAlgorithms=ssh-rsa user@原创 2016-11-03 16:38:04 · 10726 阅读 · 0 评论 -
jgit commit手动删除的文件和通过git删除的文件
Status status=git.status().call(); Set missing=status.getMissing();//提交手动删除的文件 'rm ...' on a existing file Set removed=status.getRemoved();//list of files removed from index, but in HEAD (e.原创 2017-03-24 14:21:15 · 1966 阅读 · 0 评论 -
使用SwingWorker 点击按钮后,按钮不让点击,在处理完之后,显示为可点
public void actionPerformed(ActionEvent e) { btn_convert.setEnabled(false); new ConvtSwingWorker().execute(); } private class ConvtSwingWorker extends SwingWorker { @Override protected Void原创 2016-12-11 13:15:16 · 1975 阅读 · 0 评论 -
selenium 用java得到select下拉列表选择的值
All salezhutomhuangliuzhangtianhuaiqiyangJackmeijiDickens String selectedSale=new Select(driver.findElement(By.id("sale"))).getFirstSelectedOption().getText();assertEquals("qi", select原创 2015-09-06 15:26:28 · 7680 阅读 · 1 评论 -
selenium用java 选择倒数第二个元素
selenium用java 选择倒数第二个元素或者第三个元素、、、第n个元素的方法driver.findElement(By.xpath("(//ul[@class='dropdown-menu selectpicker']/li)[last()-1]/a/span[@class='text']")).click();原创 2015-09-07 14:53:36 · 3196 阅读 · 0 评论 -
selenium用java关闭浏览器
selenium用java关闭浏览器,我用的是firefox@After public void tearDown() throws Exception{ try{ driver.quit(); String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificat原创 2015-09-08 10:03:46 · 1965 阅读 · 0 评论 -
用java选择selenium下拉选择框的一个选项
用selenium 选择select下的optionPlease ChooseoneAdvertiserAgent可以用Select userSelect=new Select(driver.findElement(By.id("User_user_type")));userSelect.selectByVisibleText("Advertiser");或者WebEl原创 2015-08-31 17:04:28 · 8465 阅读 · 0 评论 -
selenium java下载图片
selenium不能处理操作系统级别的对话框原创 2019-11-20 17:06:17 · 472 阅读 · 0 评论 -
selenim java判断图片有没有加载完成
WebDriver只会检查DOM中是否有image 标记,而不能检查这个图片是否不可见或者坏掉。检查图片是否可见,可通过检查javascript属性naturalWidth是否大于0@Test public void Test1() throws Exception{...... WebElement image=driver.findElement(By.cssSelector("div原创 2015-08-12 15:50:46 · 2043 阅读 · 0 评论 -
javax.imageio.IIOException: Not a JPEG file: starts with 0x47 0x49
java处理图片时出现异常javax.imageio.IIOException: Not a JPEG file: starts with 0x47 0x49at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImageHeader(Native Method)at com.sun.imageio.plugins.jpeg.JPEGI原创 2015-08-26 15:30:12 · 8009 阅读 · 0 评论 -
java读取properties配置文件时中文乱码解决办法
代码如下:package com.test;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;import java.util.Properties;public class ConProperty { private Properti原创 2015-08-26 14:51:39 · 5636 阅读 · 1 评论 -
java按行读取text文件
用java一行一行的读取文件里的内容文件路径为:项目/resources/category.txt项目/src/com/test/file/ReadStringFromFileLineByLine.java代码为package com.test.file;import java.io.BufferedReader;import java.io.File;impo原创 2015-10-20 17:14:36 · 1057 阅读 · 0 评论 -
随机读取txt文件的某一行
随机读取txt文件的某一行,每一行的概率都是一样的public static String choose(File f) throws FileNotFoundException{ String result = null; Random rand = new Random(); int n = 0; for(Scanner sc = new原创 2015-10-26 13:00:29 · 4642 阅读 · 1 评论 -
java JTextArea append之后自动滚动到最后一行,不需要在swing主线程完成之后才显示
public void actionPerformed(ActionEvent e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); new Thread(new Runnable() { @Override public void run() { //原创 2016-12-11 12:00:58 · 1943 阅读 · 1 评论 -
java JTextArea append之后自动滚动到最后一行
DefaultCaret caret = (DefaultCaret) log.getCaret();caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);原创 2016-12-11 11:42:38 · 2255 阅读 · 0 评论 -
如何在终端运行jar文件
执行命令java -jar test.jar原创 2016-11-02 18:31:32 · 20769 阅读 · 3 评论 -
java将exception的stack trace 转为string
StringWriter sw = new StringWriter();PrintWriter pw = new PrintWriter(sw);e.printStackTrace(pw);sw.toString(); // stack trace as a string原创 2016-11-02 15:09:22 · 1441 阅读 · 0 评论 -
java执行git命令
使用JGit private Git git=null; public void CommitCode(String proName,String proPath) throws IOException, NoFilepatternException, GitAPIException { try{ Repository existingRepo = new FileReposi原创 2016-11-09 17:30:37 · 9147 阅读 · 2 评论 -
selenium java等待alert对话框弹出,并关闭对话框
private void waitForAlertAndCloseAlert(WebDriver driver) throws InterruptedException { int i=0; while(i++<10) { try { Alert alert = driver.swi原创 2016-05-11 17:42:27 · 4188 阅读 · 0 评论
分享