<%@ page contentType="text/html; charset=gb2312"%> java进度条
网站公告:   ◆北天JAVA技术网热情为java爱好者服务,本网内容包括JAVA(JSP、servlet、EJB、webservice、j2ee、javabean、应用服务器、JavaScript),数据库(MYSQL、SQL Server、Sybase、Oracle、DB2、数据库综合知识),设计研究(设计模式、Struts、Spring、Hibernate、设计框架、设计综合知识),WEB2.0新技术(主要介绍AJAX),以及各种技术的入门、实例、例子等等,欢迎各位多来坐坐!◆  诚邀各位JAVA爱好者加盟!◆  本网站内容丰富,更新快,保证每周20篇以上!  
加入收藏
设为首页
联系站长
承接项目
  相关资源:网站首页 | 免费培训学院 | 技术论坛 | JAVA聊天室 | 作家专栏 | 开发工具 | 认证考试 | 会员俱乐部
  JAVA技术初学者园地 | jsp与servlet | javascript | Java源代码 | EJB | web service | 应用服务器 | JAVA综合知识
  设计研究设计模式 | 设计框架 | Struts | Spring | Hibernate | 开源项目 | 面向对象设计 | 设计综合知识
  数 据 库MYSQL | SQL Server | Sybase | Oracle | DB2 | Informix | Access | 数据库综合知识
  其他资源:AJAX新技术 | 网站开发 | ERP软件 | OA办公软件 | 商业智能BI | 开发综合知识 | 承接项目 | 项目试用

 
 
java进度条
     发布者: 发布时间:2007-01-02

 


import java.io.IOException;


public class TextProcess 
{

private static final int terminalLen = 60;

private float percent = 0.0f;

private float oldPercent = percent;

private String desc = "Running:";

private String processTxt = "=";

private int preLen = 0;

private final static byte[] bytes = new byte[] { 92, 124, 47 };

private int bi = 0;

private boolean stop = false;

public static void main(String[] args) throws IOException 
{
TextProcess test = new TextProcess();
test.run();
float per = 0.0f;
for (int i = 0; i < 100; i++) 
{
per += 0.01;
test.setPercent(per);
try 
{
Thread.sleep(200);
} catch (InterruptedException e) 
{
}
}
test.stop();
}

public void stop() 
{
this.stop = true;
}

public void run() 
{
Thread run = new Thread() 
{
public void run() 
{
while (!stop) 
{
try 
{
TextProcess.this.print();
Thread.sleep(100);
}
catch (Exception e) 
{
}

}

}
};

run.start();
}

public void print() throws IOException 
{
for (; preLen > 0; preLen--) 
{
System.out.write(8);
}
System.out.print(this.desc);
preLen = this.desc.length();
int processLen = (int) ((terminalLen-preLen) * this.percent);
for (int i = 0; i < processLen; i++) 
{
System.out.print(this.processTxt);
preLen++;
System.out.flush();
}
for(int i=terminalLen-preLen;i>0;i--)
{
System.out.print(' ');
preLen++;
}
System.out.write(bytes[bi]);
bi = ++bi % 3;
preLen++;
String txtPer = String.valueOf(Math.round(this.percent * 100)) + "%";
System.out.print(txtPer);
preLen += txtPer.length();
}


public static byte[] getBytes()
{
return bytes;
}

public TextProcess(String desc, String processTxt) 
{
super();
this.desc = desc;
this.processTxt = processTxt;
}

public TextProcess() 
{
}

public String getDesc() 
{
return desc;
}

public void setDesc(String desc) 
{
this.desc = desc;
}

public String getProcessTxt() 
{
return processTxt;
}

public void setProcessTxt(String processTxt) 
{
this.processTxt = processTxt;
}

public float getPercent() 
{
return percent;
}

public void setPercent(float percent) 
{
this.percent = percent;
}

}
(转载文章请保留出处:北天JAVA技术网(www.java114.com))
 
更多精彩文章:
商业智能和决策分析
OA办公软件闹革命 阵营开始分化
ERP走向平台化
YODODO苗湾儿:为自己的梦想打工
数据库综合知识
保护Access 2000数据库的安全
 
最近评论:
        
你曾悄悄的来过!
wow gold,wow gold,wow gold,ffxi gil max(526)
        
冰封的往事!
wow power leveling,wow gold,wow power leveling,wow gold max(3753)
        
冰封的往事!
wow power leveling,wow gold,WoW Gold,wow gold max(5488)
        
飞舞的传奇!
传世私服,传世私服.传奇世界私服传奇世界私服,传世私服传世私服, 传奇世界私服传奇世界私服.传奇私服传奇私服. max(7047)
        
标 题:   
内 容:   
 
                                  
 
免责声明:该文章由网友发表,如果对您造成侵权,请联系站长

首页 - 承接项目 - 网站地图 - 联系我们 -
版权所有北天JAVA技术工作室 ICP证号:粤ICP备06079815号