随笔分类 -  java

摘要:文件下载 1. 直接向response的输出流中写入对应的文件流 @GetMapping("/download1") @ResponseBody public String download1(HttpServletResponse response){ FileInputStream fileIn 阅读全文
posted @ 2022-09-09 13:14 panther125 阅读(100) 评论(0) 推荐(0) 编辑
摘要:一、导入jar包 下载jar包 https://www.jb51.net/softs/546820.html 二、配置xml文件 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/ja 阅读全文
posted @ 2022-07-23 17:47 panther125 阅读(149) 评论(0) 推荐(0) 编辑
摘要:一、 获取所有目录 public static class DeleteNullDirectory { public List getAllDirectorys(File root) { List list = new ArrayList(); File[] dirs = root.listFile 阅读全文
posted @ 2022-06-20 16:23 panther125 阅读(1145) 评论(0) 推荐(0) 编辑
摘要:一、Cookie 1. 创建Cookie /** * 创建一个新的Cookie可同时创建多个 * @author: panther * @date: 2022/6/9 10:31 * @param: [req, resp] * @return: void **/ protected void cre 阅读全文
posted @ 2022-06-10 00:04 panther125 阅读(26) 评论(0) 推荐(0) 编辑
摘要:一、HashMap底层实现 HashMap底层结构:数组+链表+红黑树 Java中的HashMap是以键值对(key-value)的形式存储元素的。HashMap需要一个hash函数,它使用hashCode()和equals()方法来向集合/从集合添加和检索元素。当调用put()方法的时候,Hash 阅读全文
posted @ 2022-04-29 12:12 panther125 阅读(33) 评论(0) 推荐(0) 编辑
摘要:UDP聊天案例 1.分别建立一个接受端作为聊天内容的接收,创建多个客服端发送信息 接受端 public static void main(String[] args) throws IOException { //定义一个指定端口的接收端对象,开放端口接受数据 DatagramSocket serv 阅读全文
posted @ 2022-04-25 12:01 panther125 阅读(34) 评论(0) 推荐(0) 编辑
摘要:UDP Inetaddress常用方法 方法声明 功能描述 InetAddress getByName(String host) 获取指定主机的IP地址 InetAddress getLocalHost() 获取本地主机地址 String getHostName() 获取本地主机的主机名 boole 阅读全文
posted @ 2022-04-25 11:45 panther125 阅读(46) 评论(0) 推荐(0) 编辑
摘要:一、同步代码块 lock是一个锁对象,它是同步代码块的的关键 class myThread2 implements Runnable{ private int tickets =10; private final Object lock = new Object();//任意对象类型 @Overri 阅读全文
posted @ 2022-04-24 12:05 panther125 阅读(38) 评论(0) 推荐(0) 编辑
摘要:一、创建多线程的方法 1.通过继承Thread类实现多线程 class myThread extends Thread{ public myThread(String name){ super(name); } @Override public void run() { int i=0; while 阅读全文
posted @ 2022-04-23 20:37 panther125 阅读(58) 评论(0) 推荐(0) 编辑
摘要:JDBC的编程步骤 第一步:注册驱动(告诉Java程序,即将要连接那个品牌的数据库) 第二步:获取连接(表示JVM的进程和数据库进程之间的通道打开了,这属于进程之间的通信,重量级的,使用完后一定要关闭) 第三步:获取数据库操作对象(专门执行sql语句的对象) 第四步:执行SQL语句(DQL DML 阅读全文
posted @ 2022-04-19 12:38 panther125 阅读(43) 评论(0) 推荐(0) 编辑
摘要:1 public static void main(String[] args) throws IOException { 2 //创建RandomAccessFile源文件 3 RandomAccessFile rabsrc = new RandomAccessFile("mm.png","rw" 阅读全文
posted @ 2022-04-17 00:16 panther125 阅读(43) 评论(0) 推荐(0) 编辑
摘要:List、Map、Set的区别与联系 一、结构特点 `List`和`Set`是存储单列数据的集合,`Map`是存储键值对这样的双列数据的集合; `List`中存储的数据是有顺序的,并且值允许重复;`Set`中存储的数据是无顺序的,并且不允许重复,但元素在集合中的位置是由元素的`hashcode`决定 阅读全文
posted @ 2022-04-14 21:01 panther125 阅读(188) 评论(0) 推荐(0) 编辑
摘要:Collections ArrayList<String> al = new ArrayList<>(); //static boolean addAll(Collection<? super T> c,T... elements) Collections.addAll(al, "john", "r 阅读全文
posted @ 2022-04-13 18:38 panther125 阅读(66) 评论(0) 推荐(0) 编辑
摘要:List `ArrayList` 的底层是数组队列,相当于动态数组。与 Java 中的数组相比,它的容量能动态增长。在添加大量元素前,应用程序可以使用`ensureCapacity`操作来增加 ArrayList 实例的容量。这可以减少递增式再分配的数量。 ArrayList继承于 `Abstrac 阅读全文
posted @ 2022-04-12 23:49 panther125 阅读(37) 评论(0) 推荐(0) 编辑
摘要:System.arraycopy() 方法 // 我们发现 arraycopy 是一个 native 方法,接下来我们解释一下各个 //参数的具体意义 /** * 复制数组 * @param src 源数组 * @param srcPos 源数组中的起始位置 * @param dest 目标数组 * 阅读全文
posted @ 2022-04-12 17:45 panther125 阅读(178) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示