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

java 生成xml文件

import java.awt.Image;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public class createXml
{
public static boolean writeXml(String path,String dir,String wpath,String wname)
{
File[] files = ReaderListFiles(path);
boolean flag = false;
if(files!=null)
{
StringBuffer xml = ReaderFilesContent(files,dir);
if(xml!=null)
flag = writeXmlFile(wname,wpath,xml);
}

return flag;
}

private static File[] ReaderListFiles(String path)
{
File file = new File(path);
if(file.exists()&&file.isDirectory())
return file.listFiles();
else if(file.exists()&&file.isFile())
{
File[] files = new File[1];
files[0] = file;
return files;
}
else
return null;
}

private static StringBuffer ReaderFilesContent(File[] files,String dir)
{
StringBuffer txml = new StringBuffer();
for(int i=0;i<files.length;i++)
{
String filename = files[i].getName();
String temp = filename.substring(filename.lastIndexOf(".")+1);
if(temp!=null&&(temp.equals("gif")||temp.equals("jpg")||temp.equals("bmp")||temp.equals("jpeg")||temp.equals("png")))
txml.append(getImgDesc(filename,temp,dir,files[i]));
}
if(txml.length()>0)
{
StringBuffer xml = new StringBuffer("<?xml version='1.0' encoding='GBK'?>\r\n");
xml.append("<firstnode>\r\n");
xml.append(txml);
xml.append("</firstnode>");
return xml;
}
else
return null;
}

private static StringBuffer getImgDesc(String filename,String type,String dir,File file)
{
Image imgSrc;
StringBuffer xml = new StringBuffer();
try {
imgSrc = ImageIO.read(file);
int width = imgSrc.getWidth(null);
int height = imgSrc.getHeight(null);
xml.append("\t<secondnode id=\"").append(filename).append("\">\r\n");
xml.append("\t\t<name>").append(filename).append("</name>\r\n");


相关文档:

java(Web)中相对路径,绝对路径问题总结

1.基本概念的理解
  绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:\xyz\test.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个
URL绝对路径。
  相对路径:相对与某个基准目录的路径。包含Web的相对路径(HTML中的相对目录),例如:在 ......

Java clone机制

1、 Java对象赋值
Java代码
Employee e1=
new
 Employee(
"李"
); 
//Employee是一个自定义类 
  
Employee e2=e1; //赋值对象 
  
e2.setName("王"
);
//改变对象e2的名字 
  
System.out.println(e1.getName ......

JAVA中的传递都是值传递吗?有没有引用传递呢?

JAVA中的传递都是值传递吗?有没有引用传递呢?
在回答这两个问题前,让我们首先来看一段代码:
Java代码
public class ParamTest {
// 初始值为0
protected int num = 0;
// 为方法参数重新赋值
public void change(int i) {
i = 5;
}
// 为方法参数重新赋值
public void change(ParamTest t) {
P ......

Oracle调用Java代码

 Oracle中可以调用Java的代码,一般通过两种方式进行调用,一个是直接将Java代码写在Oracle内部,另外一种是将编译好的class文件载入到Oracle中。
-A-
1、在SQLPlus中创建Oracle中的Java类与方法(方法必须是静态公有方法)
create or replace and compile java source named hello as
public class Hello {
pu ......

JAVA里 apache,tomcat,jboss 服务器

tomcat为一个jsp和servlet的容器,但它除了这个外还自带了web服务器。也就是说,它既是servlet容器,也是一个web服务器。
它是用java编写的,用来执行servlet和jsp的,但处理静态资源上apache等专业服务器功能那么强。所以很多人愿意将两者结合起来使用。tomcat处理动态页面,而appache处理静态资源,这样两者各取所长。另 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号