目录
1 正则表达式中的字符集
正则表达式回顾:https://blog.csdn.net/qq_43711904/article/details/96114479
校验电话号码:^[1][345789][0-9]{9}$
校验IP地址:
192.168.1.1 规则:一共四组,每一组都是0-255。分为以25开头或2开头或1开头的情况。
^((25[0-5]|2[0-4]\\d|[1]{1}\\d{1}\\d{1}|[1-9]{1}\\d{1}|\\d{1})($|(?!\\.$)\\.)){4}$
校验邮箱:^[a-z0-9A-Z]+[- | a-z0-9A-Z . _]+@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-z]{2,}$
2 日期、日历中常用方法
//日期 // DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss E"); // // System.out.println("系统时间:" + new Date()); // System.out.println("系统时间毫秒数:" + System.currentTimeMillis()); // System.out.println("格式化日期:" + df.format(new Date())); // System.out.println("指定日期转换:" + new SimpleDateFormat("yyyy-MM-dd").parse("1998-3-4")); // System.out.println("一个常规的数字转换实例:" + NumberFormat.getInstance().format(123456)); // System.out.println("一个货币格式数字转换实例:" + NumberFormat.getCurrencyInstance().format(123456)); //日历 // Calendar c = Calendar.getInstance(); // c.setTime(new Date()); //设置时间参照点 // System.out.println("DAY_OF_YEAR:" + c.get(Calendar.DAY_OF_YEAR)); // System.out.println("DAY_OF_MONTH:" + c.get(Calendar.DAY_OF_MONTH)); // c.set(Calendar.DAY_OF_MONTH, 17); //设置日期为本月的第17天 // System.out.println("DAY_OF_WEEK:" + c.get(Calendar.DAY_OF_WEEK)); // c.add(Calendar.DAY_OF_MONTH, 5); //设置日期为今天的后5天 // System.out.println("DAY_OF_MONTH:" + c.get(Calendar.DAY_OF_MONTH)); |
3 BigInteger、BigDecimal基础用法
import java.math.BigDecimal; public class Practise_01 { public static void main(String[] args) { //加法 } |
4 文件
文件操作回顾:https://blog.csdn.net/qq_43711904/article/details/96427231
File类代表与平台无关的文件和目录。
File能新建、删除、重命名文件和目录,但File不能访问文件内容本身。如果需要访问文件内容本身,则需要使用输入/输出流。
5 IO流(字节流重要)
字节流与字符流回顾:https://blog.csdn.net/qq_43711904/article/details/96435532
//递归实现输出指定目录下的所有子文件 public class PrintIO { |
6 回顾:序列化
对象序列化:https://blog.csdn.net/qq_43711904/article/details/96638740
7 随机文件访问流
RandomAccessFile类可以实现文件的跳跃式读取,即可以只读取文件中的部分内容,但是要求数据的保存位数确定,适合庞大文件的读取。该类中方法:public RandomAccessFile(File file,String mode) throws FileNotFoundException。其中,文件处理模式:r(只读)、rw(读写)
- 基础运用:
import java.io.*; public class RandomAccessFileDemo { public static void main(String[] args) throws Exception { File file = new File("d:" + File.separator + "a.txt") ; RandomAccessFile raf = new RandomAccessFile(file, "rw") ; // 写数据,数组中数据现在是每行5+4=9字节;int占4个字节 // String str[] = new String[] {"abcde","abc ","ab "} ; //位数一致 // int num[] = new int[] {20, 30, 10} ; // for(int x = 0 ; x < str.length; x ++) { // raf.write(str[x].getBytes()) ; // raf.writeInt(num[x]) ; // } // raf.close(); // 读数据 { //读取“ab ”,需要跳到18位(一个字节八位) raf.skipBytes(18) ; //向下跳 byte[] data = new byte[5] ; int len = raf.read(data) ; System.out.println(new String(data, 0, len).trim() + "-" + raf.readInt()); } { //读取“abc ” raf.seek(9) ; //向回跳,回到第九位处 byte[] data = new byte[5] ; int len = raf.read(data) ; System.out.println(new String(data, 0, len).trim() + "-" + raf.readInt()); } { //读取“abcde” raf.seek(0) ; //向回跳,回到头 byte[] data = new byte[5] ; int len = raf.read(data) ; System.out.println(new String(data, 0, len).trim() + "-" + raf.readInt()); } raf.close() ; } } |
- 拷贝大数据量文件
-------------------------------------------主线程分模块复制------------------------------------------ //多线程复制大文件 public class TestCopy { import java.io.IOException; //自定义子线程类 |