易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 :

Java nio 异步套接字


import java.nio.*;   
import java.nio.channel.*;   
import java.io.*;   
public static void copy(File source, File dest) throws IOException {   
 FileChannel in = null, out = null;   
 try {    
  in = new FileInputStream(source).getChannel();   
  out = new FileOutputStream(dest).getChannel();   
    
  long size = in.size();   
  MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);   
    
  out.write(buf);   
  if (in != null) in.close();   
  if (out != null) out.close();   
 }   
} &n ......

java字符串编码类型获取

http://xxw8393.blog.163.com/blog/static/37256834200910432656672/
Encoding.java
package org.loon.test.encoding;
/** *//**
 * <p>
 * Title: LoonFramework
 * </p>
 * <p>
 * Description:编码基本类型集合
 * </p>
 * <p>
 * Copyright: Copyright (c) 2008
 * </p>
 * <p>
 * Company: LoonFramework
 * </p>
 * <p>
 * License: http://www.apache.org/licenses/LICENSE-2.0
 * </p>
 *
 * @author chenpeng
 * @email:ceponline@yahoo.com.cn
 * @version 0.1
 */
public class Encoding ...{
    // 支持的字符格式
    public static int GB2312 = 0;
    public static int GBK = 1;
   
    public static int BIG5 = 2;
    public static int UTF8 = 3;
    public static int UNICODE = 4;
    public static int EUC_ ......

java HashSet去重示例

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public class HashSetDemo {

public static void main(String[] args){
List tableList = new ArrayList();
tableList.add("hello");
tableList.add("hell0");
tableList.add("world");
tableList.add("world");
tableList.add(2);
tableList.add(2);
tableList.add(true);
tableList.add(true);
HashSet hs = new HashSet(tableList);
//System.out.println(hs.toString());
//System.out.println(tableList);
Iterator i = hs.iterator();
while(i.hasNext()){
Object temp = i.next();
System.out.println(temp.toString());
}
}
}
输出:
 2
true
hell0
hello
world ......

Java JNI

http://xxw8393.blog.163.com/blog/static/3725683420091023535411/
 
Java 的出现给大家开发带来的极大的方便。但是,如果我们有大量原有的经过广泛测试的非Java代码,将它们全部用Java来重写,恐怕会带来巨大的工作量和长期的测试;如果我们的应用中需要访问到特定的设备,甚至是仅符合公司内部信息交互规范的设备,或某个特定的操作系统才有的特性,Java就显得有些力不从心了。面对这些问题,Sun公司在JDK1.0中就定义了JNI规范,它规定了Java应用程序对本地方法的调用规则。

回页首
实现步骤及相关函数使用
本文将一步步说明在Linux平台下如何实现本地共享库与Java协同工作。Hello World程序是目前标准的入门第一步,那么,我也以类似的应用最为样例。
第一步,定义一个 Java 类 -- Hello. 它提供SayHello方法:
此时应注意两点:
1.为要使用的每个本地方法编写本地方法声明,其声明方式与普通 Java 方法接口没什么不同,只是必须指定 native 关键字,如下所示:
de>public native void SayHello(String strName);de>
在这个函数中,我们将根据传进的人名,向某人问好。
2.必须显式地加载本地代码库。我们需在类的一个静态块中加载这个库:
......

Java中压缩与解压 中文文件名乱码解决办法

http://xxw8393.blog.163.com/blog/static/37256834200993051226320/
java对於文字的编码是以 unicode为基础,因此,若是以ZipInputStream及ZipOutputStream来处理压缩及解压缩的工作,碰到中文档名或路径,那当然是以unicode来处理罗!但是,现在市面上的压缩及解压缩软体,例如winzip,却是不支援unicode的,一碰到档名以unicode编码的档案,它就不处理。那要如何才能做出让WinRar能够处理的压缩档呢?那就得从修改ZipInputStream及ZipOutputStream对於档名的编码方式来着手了。我们可以从jdk的src.zip取得ZipInputStream及ZipOutputStream的原始码来加以修改
一、ZipOutputStream.java
1.从jdk的src.zip取得ZipOutputStream.java原始码,另存到一个新文件中,档名改为CnZipOutputStream.java。
2.开始修改原始码,将class名称改为CnZipOutputStream
3.建构式也必须更改为CnZipOutputStream
4.新增member,这个member记录编码方式
  private String encoding="UTF-8";
5.再新增一个建构式(这个建构式可以让这个class在new的时候,设定档名的编码)
  public CZipOutputStream(OutputStream out,String encoding) {
     this(out); ......

java中文乱码

1、输出中文。
JAVA在网络传输中使用的编码是"ISO-8859-1",故在输出时需要进行转化,如:
String str="中文";
str=new String(str.getBytes("GB2312"),"8859_1");
但如果在编译程序时,使用的编码是“GB2312”,且在中文平台上运行此程序,不会出现此问题,一定要注意。
2、从参数中读取中文
这正好与输出相反如:
str=new String(str.getBytes("8859_1"),"GB2312");
如果还不行正常显示,则还要进行下面的转换:
如:name=new String(name.getBytes("ISO-8859-1"),"GBK"); ......
总记录数:40319; 总页数:6720; 每页6 条; 首页 上一页 [190] [191] [192] [193] 194 [195] [196] [197] [198] [199]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号