随笔分类 -  java基础

获取文件后缀名
摘要:FilenameUtils.getExtension(file.getOriginalFilename()) 阅读全文

posted @ 2019-03-09 14:51 蝌蚪的精神 阅读(188) 评论(0) 推荐(0)

替换html字符串中img标签src的值.
摘要:package com.junlenet.common.util; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * html处理工具类 * @author huweijun * @date 2016年7月13日 下午7:25:09 */ public class HtmlUtils { ... 阅读全文

posted @ 2018-10-17 13:18 蝌蚪的精神 阅读(588) 评论(0) 推荐(0)

定时器
摘要:public class Demo { private long time;//间隔的时间 private Runnable task;//指定的任务 private boolean flag = true; private Thread th = null;//默认为nul... 阅读全文

posted @ 2014-05-03 22:49 蝌蚪的精神 阅读(144) 评论(0) 推荐(0)

udp群聊
摘要:package cn.charp3;import java.net.DatagramSocket;import java.net.SocketException;public class charDemo { public static void main(String[] args) throws Exception { DatagramSocket send=new DatagramSocket(); DatagramSocket rece=new DatagramSocket(10001); new Thread(new Send(... 阅读全文

posted @ 2012-11-20 15:55 蝌蚪的精神 阅读(228) 评论(0) 推荐(0)

ud类型聊天
摘要:public static void main(String[] args)throws Exception { System.out.println("发送数据、、、"); DatagramSocket ds=new DatagramSocket(); String str="我来了udp"; BufferedReader bufr=new BufferedReader(new InputStreamReader(System.in)); String line=null; while(... 阅读全文

posted @ 2012-11-20 15:04 蝌蚪的精神 阅读(217) 评论(0) 推荐(0)

UDP数据发送
摘要:import java.net.*;class netDemo{ public static void main(String[] args)throws Exception { System.out.println("发送数据。。。。。"); DatagramSocket ds=new DatagramSocket(); String str="哥来了"; byte[] buf=str.getBytes(); DatagramPacket dp=new DatagramPacket(buf,buf.length... 阅读全文

posted @ 2012-11-19 23:26 蝌蚪的精神 阅读(181) 评论(0) 推荐(0)

日期Calendar
摘要:import java.util.*;import java.text.*;class DateDemo{ public static void main(String[] arhgs) { String[] month={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"}; Stri 阅读全文

posted @ 2012-11-19 10:44 蝌蚪的精神 阅读(184) 评论(0) 推荐(0)

ArrayList 去除重复元素
摘要:import java.util.*;class ArrayListDemo{ public static void main(String[] args) { ArrayList arr=new ArrayList(); arr.add("java01"); arr.add("java01"); arr.add("java02"); arr.add("java03"); arr.add("java01"); arr.add("java05"); sop(arr); ... 阅读全文

posted @ 2012-11-15 09:52 蝌蚪的精神 阅读(264) 评论(0) 推荐(0)

枚举
摘要:public abstract class WeekDay { private WeekDay(){} private final static WeekDay MON=new WeekDay(){ @Override public WeekDay nextday() { // TODO Auto-generated method stub return SUN; } }; final static WeekDay SUN=new WeekDay(){ @... 阅读全文

posted @ 2012-11-11 15:18 蝌蚪的精神 阅读(119) 评论(0) 推荐(0)

装饰练习
摘要:public class zhuangshiDemo{ public static void main(String[] args) { new superperson(new person()).eat(); }}class person{ public void eat() { System.out.println("吃家常饭"); }}class superperson{ private person p; public superperson(person p) { this.p=... 阅读全文

posted @ 2012-11-01 22:41 蝌蚪的精神 阅读(117) 评论(0) 推荐(0)

数组翻转 字符串翻转
摘要:package awt;class DemoString{ public static void main(String[] args) { int[] arr={2,34,2,2,343,32,33}; select(arr); print(arr); } public static void select(int[] arr) { int[] ar=new int[arr.length]; for(int start=0,end=arr.length-1;start<end;star... 阅读全文

posted @ 2012-10-29 22:04 蝌蚪的精神 阅读(196) 评论(0) 推荐(0)

反射练习
摘要:package fanshe;import java.lang.reflect.Constructor;import java.lang.reflect.Field;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;public class testDemo { public static void main(String[] args) throws Exception { method_9(); } private static void me... 阅读全文

posted @ 2012-10-23 15:22 蝌蚪的精神 阅读(162) 评论(0) 推荐(0)

正则表达式
摘要:package fanshe;import java.lang.reflect.Constructor;import java.lang.reflect.Field;import java.lang.reflect.InvocationTargetException;import java.lang.reflect.Method;public class testDemo { public static void main(String[] args) throws Exception { method_9(); } private static void me... 阅读全文

posted @ 2012-10-23 15:16 蝌蚪的精神 阅读(169) 评论(0) 推荐(0)

ObjectOutputStream ObjectInputStream 对象序列化
摘要:public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException { writerObj(); readerObj(); } private static void readerObj() throws IOException, ClassNotFoundException { ObjectInputStream ois=new ObjectInputStream(new FileInput... 阅读全文

posted @ 2012-10-22 20:57 蝌蚪的精神 阅读(119) 评论(0) 推荐(0)

合并分割后的文件
摘要:public static void main(String[] args) throws IOException { File dir=new File("c:\\artfiles"); mergeFile(dir); } public static void mergeFile(File dir) throws IOException { ArrayList<FileInputStream> al=new ArrayList<FileInputStream>(); for(in... 阅读全文

posted @ 2012-10-22 13:36 蝌蚪的精神 阅读(134) 评论(0) 推荐(0)

切割文件
摘要:public static void main(String[] args) throws IOException { File file=new File("寸草心.mp3"); splitFile(file); } public static void splitFile(File file) throws IOException{ FileInputStream fis=new FileInputStream(file); byte[] buf=new byte[1024*1024]; ... 阅读全文

posted @ 2012-10-22 11:10 蝌蚪的精神 阅读(138) 评论(0) 推荐(0)

搜索目录指定文件并存储指定类型文件类型
摘要:public static void method_3() { File dir=new File("F:\\网络教材"); FilenameFilter filter=new FilenameFilter(){ @Override public boolean accept(File dir, String name) { // TODO Auto-generated method stub return name.endsWith(".pdf"); ... 阅读全文

posted @ 2012-10-20 17:41 蝌蚪的精神 阅读(197) 评论(0) 推荐(0)

使用次数配置信息练习Properties
摘要:package FileDemo;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.util.Properties;public class FileDemo { public static void main(String[] args) throws IOException { ... 阅读全文

posted @ 2012-10-20 16:29 蝌蚪的精神 阅读(151) 评论(0) 推荐(0)

Properties配置文件练习
摘要:package IO.file.test;import java.io.BufferedReader;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.InputStream;import java.io.ObjectInputStream;import jav 阅读全文

posted @ 2012-10-19 23:20 蝌蚪的精神 阅读(141) 评论(0) 推荐(0)

Properties数据读取
摘要:package IO.file.test;import java.util.Properties;import java.util.Set;public class PropertiesDemo { public static void main(String[] args) { Properties pro=new Properties(); pro.setProperty("zhangsan", "30"); pro.setProperty("lisi", "32"); pro.setProperty(&quo 阅读全文

posted @ 2012-10-19 22:01 蝌蚪的精神 阅读(117) 评论(0) 推荐(0)

导航