- 浏览: 18073 次
- 性别:
- 来自: 上海
文章分类
最新评论
============ the file name: FileTest.java
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileTest {
public static void main(String[] args) throws IOException, Exception {
long startTime = System.currentTimeMillis();
File f = new File("test");
File[] files = f.listFiles();
FileInputStream fi = null;
File outFile = new File(f.getAbsolutePath().replace("\\", "") + ".txt");
if(!outFile.exists())
outFile.createNewFile();
FileOutputStream fo = new FileOutputStream(outFile);
// StringBuffer sb;
int length = 0;
for(File file: files){
fi = new FileInputStream(file);
length =fi.available();
byte[] content = new byte[length];
fi.read(content);
fo.write(content);
System.out.println("============ the file name: " + file.getName());
System.out.println(new String(content));
}
fi.close();
fo.close();
Thread th = new Thread();
// th.sleep(100);
System.out.println("the threda's name: " + th.getName() + th.getThreadGroup() + " toString: " + th.toString());
// int sum = 0;
// for(int i = 0;i<100000;i++){
// sum +=i;
// }
// System.out.println(sum);
System.out.println(System.currentTimeMillis() - startTime);
}
}
============ the file name: MyApplet.java
============ the file name: NewFile.xml
============ the file name: SendMail.java
package test;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class sendMail
{
public static void main(String args[]) throws Exception
{
String host = "smtp.sina.com.cn";
String from = "javamail@sina.com";
String to = "javamail@china.com";
String username = "javamail";
String password = "password";
// Get system properties
// Properties props = System.getProperties(); 很多例子中是这样的,其实下面这句更好,可以用在applet中
Properties props = new Properties();
// Setup mail server
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true"); // 这样才能通过验证
// Get session
Session session = Session.getDefaultInstance(props);
// watch the mail commands go by to the mail server
session.setDebug(true);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to JavaMail");
// Send message
message.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect(host, username, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
============ the file name: Test.java
package test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
enum MyColor {
Red, Yellow, Blue , s,fsd,f,dsf,ee,
}
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
MyColor color = MyColor.f;
System.out.println(color);
for (Object mycolor : MyColor.values())
System.out.println(mycolor);
List<String> list = new ArrayList<String>();
List<?> list2 = new ArrayList<String>();
List<Integer> list3 = new ArrayList<Integer>();
list3.add(0);
for (Object integer : list3)
System.out.println(integer.getClass().getName());
// list.add(new Object());
list2.add(null);
for (Object o : list2) {
System.out.println(o);
}
}
}
============ the file name: TestCaseDemo.java
package test;
import java.io.IOException;
import junit.framework.TestCase;
import junit.framework.TestResult;
public class TestCaseDemo extends TestCase {
private int i;
public TestCaseDemo() {
System.out.println("this is the TestCaseDemo instance ... ");
}
public void testRAR() throws IOException {
System.out.println("this is a test ... ");
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
String compress = "D:/doc_c06_net.rar";// rar压缩文件
String decompression = "D:/doc_redcome_com/";// 解压路径
Process p = rt.exec("UNRAR.EXE x -o+ -p- " + compress + " "
+ decompression);
StringBuffer sb = new StringBuffer();
java.io.InputStream fis = p.getInputStream();
int value = 0;
while ((value = fis.read()) != -1) {
sb.append((char) value);
}
fis.close();
String result = new String(sb.toString().getBytes("ISO-8859-1"), "GBK");
System.out.println(result);
}
public void testrar2() throws Exception {
// Str
}
@Override
public TestResult run() {
// TODO Auto-generated method stub
System.out.println(">>>>>>>>>>>>...");
return super.run();
}
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
System.out.println(">>>>>>>>>>>>...");
super.setUp();
}
@Override
public int countTestCases() {
// TODO Auto-generated method stub
return super.countTestCases();
}
@Override
protected TestResult createResult() {
// TODO Auto-generated method stub
return super.createResult();
}
@Override
public String getName() {
return super.getName();
}
@Override
public void run(TestResult arg0) {
// TODO Auto-generated method stub
super.run(arg0);
}
@Override
public void runBare() throws Throwable {
// TODO Auto-generated method stub
super.runBare();
}
@Override
protected void runTest() throws Throwable {
// TODO Auto-generated method stub
super.runTest();
}
@Override
public void setName(String arg0) {
// TODO Auto-generated method stub
super.setName(arg0);
}
@Override
public String toString() {
// TODO Auto-generated method stub
return super.toString();
}
@Override
protected Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
return super.equals(obj);
}
@Override
protected void finalize() throws Throwable {
// TODO Auto-generated method stub
super.finalize();
}
@Override
public int hashCode() {
// TODO Auto-generated method stub
return super.hashCode();
}
@Override
protected void tearDown() throws Exception {
// TODO Auto-generated method stub
System.out.println(">>>>>>>>>>>>...");
super.tearDown();
}
}
============ the file name: TestTask.java
/*
* Created on 2007-7-9
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package test;
import java.util.*;
/**
* @author Carlos.Yang
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class TestTask extends TimerTask{
private static int i = 0;
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
// TODO Auto-generated method stub
System.out.println("this is a count: " + i++);
}
public static void main(String[] args) {
System.out.println(">>>>>>>>>>>");
}
}
============ the file name: TestTimer.java
/*
* Created on 2007-7-9
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package test;
import java.awt.List;
import java.beans.Beans;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.Timer;
import static java.lang.System.*;
;
/**
* @author Carlos.Yang
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class TestTimer {
static void prtMax(int... nums) {
System.out.println("the ... nums's type: " + nums.getClass().getName());
if (nums.length == 0) {
System.out.println(" no parameter ");
} else {
int maxNum = 0;
for (int num : nums) {
if (num > maxNum) {
maxNum = num;
}
}
System.out.println(maxNum);
}
}
public static void main(String[] args) {
String str = "dd";
int k = 2;
System.out.printf("str===%s k=%d", str, k);
System.out.println();
prtMax(1,99,4);
ArrayList<String> list = new ArrayList<String>();
list.add(new String("111"));
list.add(new String("222"));
list.add(new String("333"));
for (String bean : list) {
out.println("========" + bean);
}
// System.out.println("========start..");
// Timer timer = new Timer();
// TestTask tt = new TestTask();
// timer.schedule(tt,1000,100);
// System.out.println("..........");
//
// List<Intger> list = new Vector<Intger>;
}
}
============ the file name: ZipFloder.java
package test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
public class ZipFloder {
private static int i;
public static void main(String args[]) throws IOException {
unpack();
}
private static void unpack() throws IOException {
// TODO Auto-generated method stub
String compress = "nutch-0.9.tar.gz";// zip压缩文件
String decompression = "/f1";// 解压路径
java.io.File dir = new java.io.File(decompression);
java.util.zip.ZipFile zf = new java.util.zip.ZipFile(compress);
java.util.Enumeration enumer = zf.entries();
while (enumer.hasMoreElements()) {
java.util.zip.ZipEntry ze = (java.util.zip.ZipEntry) enumer
.nextElement();
String zename = ze.getName();
zename = new String(zename);// 文件名,不支持中文.
System.out.println(zename);
if (ze.isDirectory()) {
java.io.File file = new java.io.File(dir.getAbsolutePath()
+ "/" + zename);
file.mkdirs();
} else {
java.io.File file = new java.io.File(dir.getAbsolutePath()
+ "/" + zename).getParentFile();
if (!file.exists()) {
file.mkdirs();
}
byte zeby[] = new byte[(int) ze.getSize()];
java.io.InputStream is = zf.getInputStream(ze);
is.read(zeby);
is.close();
java.io.FileOutputStream fos = new java.io.FileOutputStream(dir
.getAbsolutePath()
+ "/" + zename);
fos.write(zeby);
fos.close();
}
}
zf.close();
}
private static void pack() throws IOException {
// TODO Auto-generated method stub
String compress = "/f2";// 要压缩的目录
String decompression = "test.rar";// 压缩路径
java.util.zip.ZipOutputStream zos = new java.util.zip.ZipOutputStream(
new java.io.FileOutputStream(new java.io.File(decompression)));
compress(zos, new File(compress));
zos.close();
System.out.println("the files count: " + i);
}
public static void compress(java.util.zip.ZipOutputStream zos,
java.io.File file) throws java.io.IOException {
if (file.isFile()) {
byte by[] = new byte[(int) file.length()];
java.io.FileInputStream is = new java.io.FileInputStream(file);
is.read(by);
is.close();
java.util.zip.ZipEntry ze = new java.util.zip.ZipEntry(file
.getPath());
zos.putNextEntry(ze);
zos.write(by);
zos.closeEntry();
System.out.println(file.getName());
} else if (file.isDirectory()) {
java.io.File files[] = file.listFiles();
if (files != null)
for (File f : files) {
compress(zos, f);
i++;
}
}
}
}
============ the file name: ZipTest.java
package test;
import java.io.*;
import java.util.zip.*;
/**
* @version Version 1.3
*/
public class ZipTest {
public static void main(String[] args) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(
new FileInputStream("fs/cb/Attribute.java"), "ISO8859_1"));
FileOutputStream f = new FileOutputStream("ziptest" + ".zip");
CheckedOutputStream ch = new CheckedOutputStream(f, new CRC32());
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
ch));
int c;
out.putNextEntry(new ZipEntry("fs/cb/Attribute.java"));
while ((c = in.read()) != -1)
out.write(c);
in.close();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
the threda's name: Thread-0java.lang.ThreadGroup[name=main,maxpri=10] toString: Thread[Thread-0,5,main]
47
相关推荐
PassMark BurnInTest V5.3 Copyright (C) 1999-2008 PassMark Software All Rights Reserved http://www.passmark.com Overview ======== Passmark's BurnInTest is a software tool that allows all the major sub...
eNetTest 网管内网单机测速工具eNetTest 网管内网单机测速工具eNetTest 网管内网单机测速工具eNetTest 网管内网单机测速工具eNetTest 网管内网单机测速工具eNetTest 网管内网单机测速工具eNetTest 网管内网单机测速...
最好用的单元测试工具,除了这里你是找不到9.0版本的破解的。 ... 独立的版本破解: ... 把lic_client.jar复制到 ... c:\Program Files (x86)\Parasoft\Test\9.0\plugins\...这个是:plugins-c++Test For Visual Studio.7z
c:\Program Files (x86)\Parasoft\C++test for Visual Studio\9.0\plugins\ 这个目录中 把plugins-Test for Virsual Studio.7z 中的文件覆盖到 c:\Program Files (x86)\Parasoft\Test for Visual Studio\9.0\...
Modeltest 使用说明 Modeltest 是一个选择核苷酸替代模型的软件,通过和 PAUP 配合使用,可以选择出合适的 MODEL,并同时计算出相关参数。下面是 Modeltest 的使用说明和相关知识点: 一、Modeltest 概述 * Model...
Parasoft C++Test 9.5是一款由Parasoft公司开发的专业自动化白盒测试工具,专注于C++编程语言的测试。它集成了多种测试策略,包括静态代码分析、动态测试、单元测试、代码覆盖率分析以及缺陷预防等功能,旨在提高...
(speedtest服务器搭建教程) 本篇教程旨在指导读者搭建speedtest服务器,通过安装PHPStudy、配置WNMP和Nginx、下载并配置speedtest测速平台,实现本地测速功能。 一、 PHPStudy 安装和配置 PHPStudy 是一个集成...
### ECU-Test高级教程知识点解析 #### 一、ECU-Test概述 **ECU-Test**是一款专为汽车电子控制单元(ECU)开发与验证而设计的强大工具。它支持自动化测试流程,并能有效管理和控制整个测试环境,极大地提高了ECU开发...
Google Test是Google开发的一款强大的C++测试框架,它使得C++开发者能够编写单元测试和集成测试,以确保代码的质量和稳定性。本文档将详细介绍Google Test框架的使用方法,包括基本概念、断言、测试套件、测试用例、...
最好用的单元测试工具,除了这里你是找不到9.0版本的破解的。 ... 独立的版本破解: ... 把lic_client.jar复制到 ... c:\Program Files (x86)\Parasoft\Test\9.0\plugins\...这个是:( plugins-Test for Virsual Studio.7z )
Test Track Client 使用说明 Test Track 是一个功能强大且实用的BUG管理软件,能够帮助测试工程师、开发工程师、开发主管和项目管理人员等角色更好地管理和跟踪项目中的BUG。该软件具有强大的管理功能和灵活的配置...
Test Bench是电子设计自动化(EDA)领域中的一个重要概念,主要用于验证数字集成电路的设计。在硬件描述语言(HDL,如Verilog或VHDL)中,Test Bench是模拟真实硬件环境来测试设计功能的一个虚拟平台。它能帮助...
CAN Test V2.53 软件使用说明 CAN Test V2.53 软件是一款功能强大且易用的CAN总线测试工具,旨在帮助用户快速地测试和诊断CAN总线设备。以下是CAN Test V2.53 软件使用说明的详细知识点: 软件安装 CAN Test 软件...
### ECU-TEST基本教程知识点概述 #### 一、ECU-TEST简介 ECU-TEST是一款由Vector公司开发的专业汽车电子控制单元(Electronic Control Unit, ECU)测试工具,它能够实现对ECU进行全面而深入的功能性测试,并且支持...
《Parasoft C++test 9.2官方用户手册_eclipse_中文版》是一本详尽的指南,专为使用C++test工具的开发者提供在Eclipse集成开发环境中的使用方法。C++test是一款强大的静态代码分析和单元测试工具,旨在提高C++软件的...
CANTest_Setup_V2.70.zip 是一个包含周立功CAN调试工具的软件安装包。这个工具主要用于汽车电子系统中的控制器局域网络(Controller Area Network, CAN)的测试和调试。CAN总线是一种广泛应用的多节点通信协议,尤其...
C++test简明操作手册 C++test是一款功能强大的测试工具,旨在帮助开发者编写高质量的代码。作为Parasoft公司的旗舰产品,C++test提供了全面的测试解决方案,涵盖了静态测试、动态测试、测试用例生成等多方面的测试...
**串口调试工具——PortTest详解** 在计算机通信领域,串行端口(Serial Port)是一种常见的硬件接口,用于设备间的通信。PortTest是一款专为串口调试设计的实用工具,它可以帮助用户检测和测试串口通讯功能,确保...