易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVA读取Properties文件的六种方法

 
使用J2SEAPI读取Properties文件的六种方法
  1。使用java.util.Properties类的load()方法示例:InputStream in=lnew BufferedInputStream(new FileInputStream(name));
properties p=newProperties(); p.load(in);
  2。使用java.util.ResourceBundle类的getBundle()方法示例:ResourceBundle rb=ResourceBundle.getBundle
(name,Locale.getDefault());
  3。使用java.util.PropertyResourceBundle类的构造函数示例:InputStream in=new BufferedInputStream(new FileInputStream
(name));ResourceBundle rb=newPropertyResourceBundle(in);
  4。使用class变量的getResourceAsStream()方法示例:InputStream in=JProperties.class.getResourceAsStream(name);
properties p=newProperties(); p.load(in);
  5。使用class.getClassLoader()所得到的java.lang.ClassLoader的getResourceAsStream()方法示例:InputStream
in=JProperties.class.getClassLoader().getResourceAsStream(name); properties p=newProperties(); p.load(in);
  6。使用java.lang.ClassLoader类的getSystemResourceAsStream()静态方法示例:InputStream
in=ClassLoader.getSystemResourceAsStream(name); properties p=newProperties(); p.load(in);
  补充
  Servlet中可以使用javax.servlet.ServletContext的getResourceAsStream()方法示例:InputStream
in=context.getResourceAsStream(path); properties p=newProperties(); p.load(in);


相关文档:

Java NIO API详解

 
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......

Java中的字符编码与解码(转)

转 http://jiangzhengjun.javaeye.com/blog/506952
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Outp ......

java生成xml格式数据

//获取数据库数据返回list
public List queryAll(int fcateId) {
List list = new ArrayList();
String sql = "select * from g_Account where fCateID=? order by fCode";
Connection con = SqlHelp.getConn();//获得连接,sqlhelp自己写的工具类
PreparedStatement pst = null;
ResultSet rs = null;
......

Java打包成可执行文件步骤详解

核心思想:把含main方法的入口类添加到MANIFEST.MF文件中。
步骤:
假设有两个类文件要打包,它们分别属于不同的package。
package com.test.jar;   
import java.awt.*;   
import javax.swing.*;   
public class Jar extends JFrame   
{  ......

在Java中实现浮点数的精确计算

标题     在Java中实现浮点数的精确计算    AYellow(原作) 修改   
关键字     Java 浮点数 精确计算  
问题的提出:
如果我们编译运行下面这个程序会看到什么?
public class Test{
    public static void mai ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号