ITeye博客

我特爱玩儿

lylegend13 · 共 58 篇文章

SAX方式,解析XML

xml文件 <bookstore> <book category="COOKING"> 0 <title lang="en">Everyday Italian</title> 1 <author>Giada De Laurentiis</author> 2 <year>2005</year> 3 <price>30.00</price> 4 </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price…

2012-10-19T23:50:00Z · 编程语言 · 评论(0)

使用反射修改final属性

情型1:static final属性,无法修改其值。 package m5.d7; import java.lang.reflect.Field; public class FieldTest { public static void main(String[] args) { try { A a = new A(); Field field = a.getClass().getDeclaredField("a"); field.setAccessible(true); field.set(a, 2); System.out.println(field.get(a)); } catch (S…

2012-05-07T22:37:57Z · 编程语言 · 评论(2)

Eclipse搭建Android开发环境

1、JDK。(当前是jdk-6u31-windows-i586.exe) 在Oracle官网(www.oracle.com)下载JDK最新版。 安装。 2、Eclipse。(当前是eclipse-java-indigo-SR2-win32.zip) 在Eclipse官网(http://www.eclipse.org/downloads/)上下载Eclipse IDE For Java Developers。 解压到E:\eclipse。 3、Android SDK。(当前是android-sdk_r16-windows.zip) 在Android SDK官网(http://developer…

2012-03-22T22:42:14Z · 移动开发 · 评论(0)

1182(未通过)

网上说用并查集,半天没看懂,我的代码题中的测试数据通过,但没通过别人给的测试数据 import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Scanner; import java.util.Set; public class t1182 { public static void main(String[] arg…

2012-02-24T15:56:18Z · 编程语言 · 评论(0)

1282(未通过)

遍历法,超时 package p1; import java.util.Scanner; public class t1282 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int r = s.nextInt(); int c = s.nextInt(); int[][] n = new int[r][c]; int[] m = new int[r]; for (int i = 0; i < r; i++) { m[i] = i; for (int j = 0; j < c; j+…

2012-02-23T17:00:12Z · 编程语言 · 评论(0)

一维数组,N皇后

import java.util.Arrays; public class test { public static void main(String[] args) { new test(); } int count = 0; public test() { int N = 6; int[] a = new int[N]; a[0] = -1; for (int i = 0; i < N; i++) { Arrays.fill(a, 1, N, -1); find(0, a, N); } System.out.println(count); } public void find(int r…

2012-02-23T14:46:57Z · 编程语言 · 评论(0)

一个Applet的练习

1. 画随机的园 功能要求:实现简单的动画.要求:自动出现由小到大变换的园,位置与颜色随机,变到150直径时擦除,重新再出现园;变换速度由html文件传入的参数控制(提示:控制sleep时间). 界面要求:用java applet实现. Java类(AppletTest.java) import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class AppletTest extends Applet { int r = 0;// 半径,从0开始到150,然后再归0 int time …

2011-12-10T20:10:08Z · 编程语言 · 评论(0)

日期“天数+1”的多种方法

说明:准确打印出日期,从今天到明年的今天,主要是2月。 1 import java.text.SimpleDateFormat; import java.util.Date; public class test { public static void main(String[] args) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date d = new Date(); int oneDayTime = 24 * 60 * 60 * 1000; long time = d.getTime(); for (int…

2011-11-11T17:13:31Z · 编程语言 · 评论(0)

NIO的使用(RandomAccessFile、Charset)

import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder;…

2011-10-17T13:35:29Z · 编程语言 · 评论(0)

NIO的使用(FileInputStream/FileOutputStream)

import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; public class test4 { static public void main(String args[]) { FileInputStream fis = null; FileOutputSt…

2011-10-17T13:34:34Z · 编程语言 · 评论(0)

Java读写xml(对复杂数据,使用中间模型)

1、创建.xml,设计.xml结构。 <?xml version="1.0"?> <Xmodel> <Xnodes> <Xnode id="n1" type="node2"></Xnode> <Xnode id="n2" type="node3"></Xnode> <Xnode id="n3" type="node4"></Xnode> </Xnodes> <Xbizs> <Xbiz id="b1" snode="n1" tnode="n2"></Xbiz> <Xbiz id="b2" snode="n3" tnode="n1"></Xbiz> </Xbizs> </Xmodel> 2、创建…

2011-10-12T15:47:42Z · 编程语言 · 评论(0)

Java读写.zip里的.xml

import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; import javax.xml.bind.JAXBContext; import javax.xm…

2011-10-11T17:03:13Z · 编程语言 · 评论(0)

Java读写xml(对简单关系,无需中间模型)

import java.io.File; import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlRootElement; public class test2 { public static v…

2011-10-11T11:26:52Z · 编程语言 · 评论(0)

Practical Java 记录

实践9: 1、不同类的对象,equals()结果false。除非重写equals()方法。 例子: Float f=1.0000000000000000000F; Double d=1.000000000000000000000000000000; System.out.println(f.equals(d));

2011-09-09T16:59:21Z · 编程语言 · 评论(0)

内部类形式的继承类

public class test { private final int a; public test(int a) { this.a = a; } private int getA() { return a; } public void exec() { new test(1) { public void print() { System.out.println(getA());// 0 } }.print(); } public static void main(String[] args) { new test(0).exec(); } } public class test { p…

2011-08-18T18:26:56Z · 编程语言 · 评论(0)