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

java获取程序当前目录。

import java.net.URL;
import java.net.URLDecoder;
public class PathUtil
{
 /**
  * Get the env of windir, such as "C:\WINDOWS".
  * @return the env of windir value.
  */
 public static String getWindir(){
  return System.getenv("windir");
 }
 
 /**
  * Get file separator, such as "/" on unix.
  *
  * @return the separator of file.
  */
 public static String getFileSeparator()
 {
  return System.getProperty("file.separator");
 }
 /**
  * Get line separator, such as "\n" on unix.
  *
  * @return the separator of line.
  */
 public static String getLineSeparator()
 {
  return System.getProperty("line.separator");
 }
 /**
  * Get programPath
  *
  * @return programPath
  */
 public static String getProgramPath()
 {
  Class<PathUtil> cls = PathUtil.class;
  ClassLoader loader = cls.getClassLoader();
  //
  // Get the full name of the class.
  //
  String clsName = cls.getName() + ".class";
  //
  // Get the package that include the class.
  //
  Package pack = cls.getPackage();
  String path = "";
  //
  // Transform package name to path.
  //
  if(pack != null)
  {
   String packName = pack.getName();
   //
   // Get the class's file name.
   //
   clsName = clsName.substring(packName.length() + 1);
   //
   // If package is simple transform package name to path directly,
   // else transform package name to path by package name's
   // constituent.
   //
   path = packName;
   if(path.ind


相关文档:

[转载]关于Java IO流学习总结

    一、IO流的三种分类方式
    1.按流的方向分为:输入流和输出流
    2.按流的数据单位不同分为:字节流和字符流
    3.按流的功能不同分为:节点流和处理流
    二、IO流的四大抽象类:
    字符流:Reader Writer
& ......

java 找出100以内的素数

 public class FindPrime {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int num = 100;
String s = "100以内的素数:";
for (int i = 1; i <= num; i++) {
int count = 0;
for (int j = 1; j <= (int) Math.s ......

java 找出4位数的所有吸血鬼数字

 /**
* 找出四位数所有的吸血鬼数字
* 吸血鬼数字:位数为偶数的数字可以由一对数字相乘而得,这对数字包含乘积一半的位数
* 如:1260 = 21*60
*/
public class Vampire {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

String s= ......

Name java:comp is not bound in this Context

 
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
在tomcat中发布web项目,可能是因为spring中配置了jndi(只配置了jndi,其他的有工具包封装了)。
启动的时候报错(在项目目录下,在tomcat中配置context指向项目目录就没问题,打包发布到
tomcat就报错了),抛的异常是:
jav ......

Java中static、this、super、final 的用法

 本篇旨在帮助准备学习Java以及刚接触Java的朋友认识、掌握和使用static、this、super、final这几个关键字的使用。Java博大精深,我也是一位正在学习和使用Java的爱好者,文中难免有不妥之处,欢迎指正。
一、static
 请先看下面这段程序:
public class Hello{
  public static void main(String[] args){ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号