在java 程序代码中 “类名.class" 怎么理解??比如下面程序中的ConnectionFactory.class

来源:百度知道 编辑:UC知道 时间:2024/05/24 01:59:26
package com.allanlxf.jdbc.util;

import java.sql.*;
import java.io.*;
import java.util.Properties;

public class ConnectionFactory
{
private static Properties config = new Properties();

static
{
InputStream in = ConnectionFactory.class.getResourceAsStream("db-config.properties");
if(in == null)
{
throw new ExceptionInInitializerError("no file:db-config.properties found error!");
}

try
{
config.load(in);
in.close();
}catch(IOException e)
{
e.printStackTrace();
throw new ExceptionInInitializerError("failed to load file!");
}
}

public static Connection getConnection() throws SQLException
{
try
{

好像返回这个类的一个类对象吧.通过这个类对象的getResourceAsStream()可以得到给定资源的字节流

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html