随笔分类 - java
摘要:Province classpackage com.apptest.xstream.test;import java.util.ArrayList;import java.util.List;public class Province { private String name; private L...
阅读全文
摘要:package com.apptest.test;import java.util.Properties;import javax.mail.Authenticator;import javax.mail.Message.RecipientType;import javax.mail.Messagi...
阅读全文
摘要:/*** Upload comoms-fileupload*/ DiskFileItemFactory diskFileItemFactory = new DiskFileItemFactory(); ServletFileUpload sfu = new Servlet...
阅读全文
摘要:分页1 什么分页第N页/共M页 首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页 口go 分页的优点:只查询一页,不用查询所有页!2 分页数据页面的数据都是由Servlet传递来的!Servlet: 当前面:pageCode,pc; pc:如果页面没有传递当前页码,那么Se...
阅读全文
摘要:package com.luowen.test;public class DealLockTest { public static void main(String[] args) { Go g1 = new Go(true); Go g2 = new Go(false); Thread ...
阅读全文
摘要:1.表单由Servlet生成一个token,用户提交表单时候,会提交token,服务端根据token判断,如果在session中有token和表单提交的相同,则让用户正确提交,并且删除session中的token,如果用户提交的token错误或者token为null则拒绝提交a. 生成token类 generateProcessor.javapackage com.luowen.formRepeat;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.util.
阅读全文
摘要:/* * java multiple upload demo * @author:luowen * @time:2013-11-06 * */import java.io.*;import java.net.*;class UploadClient{ public static void main(String[] args)throws Exception { if(args.length != 1) { System.out.println("输入错误,请正确输入"); return; ...
阅读全文
摘要:/** * java file upload demo * @author:luowen * @time:2013-11-03 */import java.net.*;import java.io.*;class UploadClient{ public static void main(String[] args)throws Exception { //建立客户端socket对象 Socket s = new Socket("127.0.0.1",10000); BufferedReader bur = new B...
阅读全文
摘要:/* * java socket send and receice demo * @author:luowen * @time:2013-11-1 * */import java.net.*;class SocketSend{ public static void main(String[] args)throws Exception { //创建socket服务 DatagramSocket ds = new DatagramSocket(); byte[] buf = "yes iam demo".getBytes(); ...
阅读全文
摘要:/* *java list file demo @author:luowen @time:2013-10-25 * */import java.io.*;import java.util.*;class FileToList{ public static void main(String[] args) { File f = new File("d:/") ; List list = new ArrayList(); toList(f,list); toFile(list); } publi...
阅读全文
摘要:/* java中字符字节的转化使用 @author:luowen @time:2013-10-24*/ import java.io.*; class ZijieZifu { public static void main(String[] args)throws IOException { //输入 InputStream in = System.in; //输出 OutputStream out = System.out; ...
阅读全文
摘要:/* java 获取输入,大写在显示 @author:luowen @time:2013-10-23*/import java.io.*;class GetParam{ public static void main(String[] args) { InputStreamReader isr = null; BufferedReader br = null; try { InputStream in = System.in; isr = new InputStreamReader(in); br = new BufferedReader(isr); ...
阅读全文
摘要:/* java 的文件复制 @author:luowen @time:2013-10-23 */import java.io.*;class TextMove{ public static void main(String[] args) throws IOException { //创建读写文件对象 FileReader fr = new FileReader("demo.txt"); FileWriter fw = new FileWriter("demo1.txt"); //创建缓冲区 BufferedReader br = new Buffere
阅读全文
摘要:/* String name = "adsbsadgsadgtewterfsdf"; eg a-->6,b-->1 d-->3 ... 将字符串以a(字母)=>2(个数)存入Map集合框架中 思路:1.将字符串转换成字符数组. 2.定义一个Map集合,然后对字符数组进行遍历,如果Map集合中没有该元素就将该元素存入Map集合中,并定义一个计数器,将次数存入Map中,来达到目的*/import java.util.*;class CharMapDemo{ public static void main(String[] args) { String s
阅读全文
摘要:class ArrayTest{ public static void main(String[] args) { int[] arr;//对数组初始化 arr = new int[100]; for (int x = 0; x < 100 ;x++ ) {//对数组的每个元素进行赋值 arr[x] = x; } for (int x = 0; x < arr.length-1 ; x++ ) {//打印每个值 System.out.println(arr[x]); } }}
阅读全文