
java不一样的基础
文章平均质量分 75
工作学习到的java、国外书籍阅读的笔记、老外博客的翻译、转载
Dreamer who
=== Happiness isn't something you experience; it's something you remember.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Java避坑指南:finally块的陷阱及正确的关闭资源方式小
正确的关闭资源方式转载:Java避坑指南:finally块的陷阱及正确的关闭资源方式小结1、使用finally块来关闭资源,保证关闭操作总是会被执行;2、关闭每个资源之前首先判断资源的引用变量不为null,避免NPE发生;3、为每个资源使用单独的try...catch 块关闭,保证关闭此资源发生异常,不会影响后面资源的关闭;4、finally块不要使用return语句。return语句直接导致方法结束,不会再跳回去执行try、catch块中的任何代码;5、不要出现Sy转载 2022-05-11 16:04:32 · 1223 阅读 · 0 评论 -
Base64 算法的应用举例
Base64 算法的应用举例1.密钥存储 写过加密解密的时候,我们都知道,API返回给我们的一般是字节数组,虽然字节数组会使得安全性有很大提升(犹如密码一样,java程序中的密码字段是使用字节数组,一般不使用string),但对于人类来说,可读性很不友好。在往日的项目中,我们一般使用的是把密钥经过Base64编码的字符串,便于我们存储、配置及传输给别人。具体代码例子,见:https:原创 2017-01-15 11:54:59 · 997 阅读 · 0 评论 -
什么,Base64 算法你用的哪个?不就一种算法实现吗
什么,Base64 算法你用的哪个?不就一种算法实现吗Base64算法最早主要是解决电子邮件的传输问题,由于当时的网关有个问题就是可能会度非ASCII码字符的二进制位做调整,导致用户收取的邮件变成乱码,所以就出现了Base64算法。算法思想见:https://zh.wikipedia.org/wiki/Base64 。经过Base64编码后的数据会比原始数据长点,为原来的4/3原创 2017-01-14 18:37:28 · 2135 阅读 · 0 评论 -
ArchUnit在代码检测方面的应用
1、为什么做代码检测功能 不管使用哪种语言,哪种框架,只要你编程,都会遇到些所谓的“坑”,只能靠代码检测工具自动发现这些问题,因为人脑或者是人并不总是最靠谱的。也行你已经用了阿里的检查插件P3C,或者SonarQube、JArchitect、checkstyle或者findbugs等等工具来检测来避免,现在介绍一款java的基于字节码的我们可以自定义的,比较通用的检测工具。2、ArchUnit 使用这个工具的目的,其实想利用java反射的方式,基于字节码解析...原创 2021-04-26 11:30:44 · 1189 阅读 · 0 评论 -
java9新特性-Stack Walking-当前线程栈信息
java语言是基于栈的设计语言,其执行的本质与c、c++语言一样,程序的运行都是一系列进栈出栈操作。JVM中的每个线程启动时都有一个私有的JVM线程栈会创建。栈这种数据结构就是我们常谈到的数据结构中的栈-后进先出的数据结构。栈保存了一系列栈帧,每当一个方法执行时都会伴随着新的栈帧的创建并进栈顶,方法执行完也都会伴随着对应的栈帧的销毁-出栈操作。有关具体细节可以参考https://docs.orac...原创 2019-10-26 23:49:22 · 722 阅读 · 0 评论 -
java开发规则:线程如何被创建
目录1、创建线程请使用线程工厂类(1)自定义线程工厂参照java.util.concurrent.Executors类中的线程工厂(2)建议使用org.apache.commons.lang3.concurrent.BasicThreadFactoryapache lang3 工具包已经提供了一个自定义线程的工厂类,所以,我们放心的使用吧。2、设置线程的UncaughtEx...原创 2019-07-21 00:09:29 · 569 阅读 · 0 评论 -
ArrayIndexOutOfBoundsException: 4096 while reading gif file
最近今天碰到某同学想把一个网址的某gif图片上传到UCloud上,碰到了一个异常:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4096 at com.sun.imageio.plugins.gif.GIFImageReader.read(GIFImageReader.java:984) ...原创 2018-06-10 12:12:26 · 4044 阅读 · 0 评论 -
java读取Excel文件
java读取Excel文件本博文使用工具https://github.com/nvenky/excel-parser,其思想类似orm,数据源来于Excel文件,Excel文件中的每一行对应java中的类实例,此工具使用注解绑定Excel每一行的中某列对应类的哪个属性(Hibernate也是这样做的,不过根据名字yin's,myabtis使用的是配置的方式)。拿某公司的原创 2017-05-21 18:21:52 · 3170 阅读 · 9 评论 -
JAX-WS Web Service -春秋航空销售部分接口使用
JAX-WS Web Service -春秋航空销售部分接口使用 春秋航空销售部分接口由于使用的是Web Service方式,只知道有这么一种接口类型,大多数我们还是用的RESTful Web Services,不过java已经实现了对应的标准接口: jax-ws 、jax-rs。 对于服务的和客户端,java都支持工具一键生成,省下了很多时间。下面用java的命令w原创 2017-05-09 10:51:34 · 2216 阅读 · 0 评论 -
java ThreadLocal 解说
java ThreadLocal 解说先把java doc搬上来:This ThreadLocal class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its ge原创 2017-01-17 18:29:39 · 668 阅读 · 0 评论 -
Effective Java
Effective Java1.考虑使用静态工厂方法而不是构造函数例如:Integer类中的: public static Integer valueOf(int i) { if (i >= IntegerCache.low && i <= IntegerCache.high) return IntegerCache.cache[i + (-原创 2016-11-09 00:21:03 · 1035 阅读 · 0 评论 -
Java Exception Handling -java异常处理
Java Exception Handling -java异常处理java中的异常异常是程序在编译时或者运行时出现的意想不到的场景,比如在书写java代码时候不遵守java语法规则会导致编译失败,操作数组,下标越界的运行时异常等等。当异常发生时会导致程序异常退出,为了避免程序异常退出,我们必须对出现的某些异常处理,让程序继续执行下去,俗称“异常恢复”。java中异常的原创 2016-09-29 00:02:21 · 2813 阅读 · 0 评论 -
java反射之Call stack introspection
java反射之Call stack introspectionjava是基于栈设计的语言,其实与C、C++语言相同。整个程序的运行表现在方法的执行是一系列入栈出栈的行为,栈是线程私有的。在java语言中,我们可以跟踪方法的调用关系,即当前栈帧(栈顶)和已经入栈的栈帧的层次关系。从java1.4以后,java语言的Throwable类提供了以下方法:S原创 2016-08-30 22:51:32 · 1469 阅读 · 0 评论 -
java反射之dynamic invocation与原生类型
java反射之dynamic invocation与原生类型java中的方法参数或者返回值可能为原生类型,反射调用方法的时候,理解在反射invoke方法中如何使用原生类型很重要。 如果方法的参数为原生类型,involve方法第二个数组参数Object... args传进去的对象如果是封装类型,involve方法会自动“拆箱”为原生类型。 /** *原创 2016-08-28 18:15:47 · 3362 阅读 · 0 评论 -
java反射基本概念
java反射基本概念1.java反射入口 在java程序中,任何对象都有其对应的Class,而Class是通向java反射的一道大门。在java中获取Class有两种方式:1.通过对象的getClass()方法;2.通过类的.class属性;/* * Copyright 2016 https://github.com/sdcuike Inc. *原创 2016-08-28 16:19:19 · 2047 阅读 · 0 评论 -
java SPI 与cooma(dubbo 微容器改良品)--2 之Cooma SPI
java SPI 与cooma(dubbo 微容器改良品)--2 之Cooma SPI Cooma是一个极简、灵活的开源Java微容器(microcontainer)实现,其实现源于dubbo的spi(它来源于java spi)。让我们看一下简单的demo:概念:Extension Point,扩展点,要扩展的接口。提倡面向接口的编程,这些接口定义就变成原创 2016-07-25 23:38:01 · 2599 阅读 · 3 评论 -
java SPI 与cooma(dubbo 微容器改良品)--1
java SPI 与cooma(dubbo 微容器改良品)--1java 的spi(Service provider interface)主要是为了框架的扩展和组件替换而产生的,与当今流行的IOC概念类似。 java spi的实现:java.util.ServiceLoaderS>A simple service-provide原创 2016-07-25 00:09:36 · 22524 阅读 · 0 评论 -
Email Header 是什么
Email Header 是什么-What is an Email Header每天都收邮件,你是否注意到一个名词:Email Header。那这个东西究竟是什么,对我们有什么意义呢。What is an Email Header 请参考链接地址:http://whatismyipaddress.com/email-header ,我也在博文底部copy了一份。原创 2016-06-26 21:47:55 · 26044 阅读 · 1 评论 -
利用Mail Exchanger (MX) Record原理 发送email
利用Mail Exchanger (MX) Record原理 发送email 发送邮件,我们一般会利用java api 发送,但是,你发送出去的邮件状态你是得不到的,比如用户不存在等,至于为什么,请参考:http://www.oracle.com/technetwork/java/javamail/faq/index.html#badaddr,很多FAQ可以去看看。java ap原创 2016-06-26 21:02:26 · 5548 阅读 · 0 评论 -
java之Database Performance Best Practices
java之Database Performance Best PracticesSpend time evaluatingthe best JDBC driver for the application. The best driver will often vary depending on the specific deployment. The same appli原创 2016-05-15 11:29:16 · 8899 阅读 · 0 评论 -
java之Secure hash functions
java之Secure hash functionsA secure hash function will generatea large number, called the hash value, when given a document of some sort. This document can be of almost any type. We will be usi原创 2016-04-16 20:44:44 · 2917 阅读 · 0 评论 -
java之Asymmetric encryption techniques
java之Asymmetric encryption techniquesAsymmetric encryption uses a public and private key. The private key is held by one entity. The public key is made available to everyone. Data can be encry原创 2016-04-16 16:43:17 · 1314 阅读 · 0 评论 -
java之Symmetric encryption techniques
java之Symmetric encryption techniquesSymmetric encryption usesa single key to encrypt and decrypt a message. This type of encryption is classified as either stream ciphers or block ciphers. Mor原创 2016-04-16 15:45:44 · 4470 阅读 · 0 评论 -
java之Secure communication terminology
java之Secure communication terminologyThere are several terms that are used when working with secure communications. These include the following:Authentication: This is the process of verifyi原创 2016-04-16 10:56:41 · 6923 阅读 · 0 评论 -
Java Monitoring Tools之jcmd
Java Monitoring Tools之jcmdjcmdPrints basic class, thread, and VM informationfor a Java process. This is suitable for use in scripts; it is executed like this:% jcmd process_idcommand原创 2016-04-07 00:14:28 · 1975 阅读 · 0 评论 -
A simple model for describing basic sources of possible performance problems
A simple model for describing basic sources of possible performance problemsIn this section we describe a simple model for describing basic sources of possible performance problems. The model is原创 2016-04-02 13:01:50 · 2505 阅读 · 0 评论 -
A Taxonomy for Performance
A Taxonomy for PerformanceIn this section, we introduce some basic performance metrics. These provide avocabulary for performance analysis and allow us to frame the objectives of atuning proje原创 2016-03-31 23:22:36 · 1193 阅读 · 0 评论 -
java基础之Classloading and class objects
java基础之Classloading and class objectsA.class file defines a type for the JVM, complete with fields, methods, inheritanceinformation, annotations, and other metadata. The class file format is wel原创 2016-03-19 21:09:32 · 1667 阅读 · 0 评论 -
java并发基础之The volatile keyword
java并发基础之The volatile keywordWhy synchronized?One of the biggest changes in concurrent programming in recent years has been inthe realm of hardware. It wasn’t that many years ago that a wo原创 2016-03-19 16:08:55 · 1862 阅读 · 2 评论 -
java7新特性之Simplified varargs method invocation
java7新特性之Simplified varargs method invocationThis is one of the simplest changes of all—it moves a warning about type informationfor a very specific case where varargs combines with generics i原创 2016-03-16 21:21:53 · 1901 阅读 · 0 评论 -
java7新特性之Diamond syntax
java7新特性之Diamond syntaxJava 7 also introduces a change that means less typing for you when dealing withgenerics. One of the problems with generics is that the definitions and setup ofinsta原创 2016-03-16 21:15:48 · 3452 阅读 · 0 评论 -
java7新特性之Try-with-resources (TWR)
java7新特性之Try-with-resources (TWR)This change is easy to explain, but it has proved to have hidden subtleties, whichmade it much less easy to implement than originally hoped. The basic idea is原创 2016-03-16 00:10:56 · 6171 阅读 · 0 评论 -
java7新特性之Improved exception handling
java7新特性之Improved exception handlingThere are two parts to this improvement—multicatch and final rethrow. To see whythey’re a help, consider the following Java 6 code, which tries to find, ope原创 2016-03-15 23:33:36 · 989 阅读 · 0 评论 -
java7新特性之Enhanced syntax for numeric literals
java7新特性之Enhanced syntax for numeric literalsThere were several separate proposals around new syntax for the integral types. Thefollowing aspects were eventually chosen:■ Numeric constants (原创 2016-03-15 23:12:48 · 1890 阅读 · 0 评论 -
java7新特性之—String values in a switch statement
java7新特性之—String values in a switch statementStrings in switchThe Java switch statement allows you to write an efficient multiple-branch statementwithout lots and lots of ugly nested ifs—l原创 2016-03-15 00:16:20 · 1310 阅读 · 0 评论 -
Best practices for the logging REST API
Best practices for the logging REST APIIn a large-scale distributed environment, the log data may be the only informationthat is available to the developer for debugging issues. Auditing and log原创 2016-03-13 12:02:17 · 1109 阅读 · 0 评论 -
RESTful之Content negotiation
Content negotiationContent negotiationContent negotiation means allowing different representations of a resource in thesame URI so that clients can make a choice on what suits them best.原创 2016-03-13 11:20:25 · 1659 阅读 · 1 评论 -
有关java.util.ConcurrentModificationException
有关java.util.ConcurrentModificationExceptionjava doc对这个类的定义:This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permiss原创 2016-03-06 11:21:42 · 3063 阅读 · 0 评论 -
利用jackson-dataformat-csv读写csv文件
利用jackson-dataformat-csv读写csv文件csv是comma-separated values的缩写,这类文件在日常项目中有时比较常见。sql工具一般具有将数据库数据导入、导出csv格式。利用jackson-dataformat-csv读写csv文件,重点在与两个类:CsvMapper和CsvSchema。其中CsvMapper和我们利用jackson转换son原创 2016-02-28 18:28:37 · 9933 阅读 · 6 评论 -
java基础之 Advanced Class Design
java基础之 Advanced Class DesignAbstract ClassesIn many programming situations, you want to specify an abstraction without specifyingimplementation-level details. In such cases, you can use e原创 2016-02-21 17:28:18 · 2418 阅读 · 2 评论