逐渐显示10个helloword,,100分招标讲懂之人:) flush方法可以强制写入底层stream,,所以缓冲区不满也会输出不用则要等到满了再一起输出,,那样就没有动态效果了, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一般情况下服务器上的jsp文件执行完成以后才会向客户端输出内容,使用out.flush()可以强制将当前执行完的内容返回给客户端进行显示,服务器端继续执行下面的语句。 使用out.flush()可以强制将当前执行完的内容返回给客户端进行显示以后也不要用这样的方法让内存跑光了你学过数据结构吗多看一看就明白了 我建议延迟的部分你可以用线程休眠得办法。<%for(int i = 0; i <= 10; i++){ Thread.sleep(3000);//这里延迟3秒,当然延迟多少你可以自己估算控制。 out.println("hello word" + "<BR>"); out.flush(); }%> 其实最理想的方式不是直接用JAVA完成,可以在页面上用JAVASCRIPT完成该功能,JAVA只提供需要输出的格式化数据 你可以想象一下,有一个储物间;现在将10个柜子搬进去,再搬出来(呵呵,这样好傻哦)有几种方法:1、一个柜子搬进去,然后立刻搬出来。2、10个柜子都搬进去,然后再搬出来。对于方法一,就是使用flush 为什么我编译时会出错class A { public static void main(String[] args) { for(int i=0;i<=10;i++) { Thread.sleep(3000); System.out.println("Hello World!"); System.out.flush(); } }}报错:---------- javac ----------A.java:8: unreported exception java.lang.InterruptedException; must be caught or declared to be thrown Thread.sleep(3000); ^1 error输出完成 (耗时 2 秒) - 正常终止 因为要执行thread.sleep()方法,必须要抛出InterruptedException异常,所以应该写成class A{ public static void main(String[] args) throws InterruptedException{ for(int i=0;i<=10;i++){ Thread.sleep(3000); System.out.println("Hello World!"); System.out.flush(); } }}或者是class A{ public static void main(String[] args){ for(int i=0;i<=10;i++){ try{ Thread.sleep(3000); } catch(InterruptedException e){ } System.out.println("Hello World!"); System.out.flush(); } }} js 如何获取当前A的值 关于数据库连接中的问题 如何在弹出窗口上放按钮 chartDirector 生成的图表,如何才能导出到word中去? 没见过也没找到关于这些资料,请知道人解答一下 Struts CheckBox标签的使用疑惑,大家帮帮忙 哪位兄弟有SimpleTagSupport源码(还有BodyTagSupport等等) |---jdk里验证日期格式的问题----| 使用applet文件上传,怎么样都接收不到东西 求助!急。。。。。。! 怎么用JSP读取服务器一个文件夹里所有文件的文件名,形成一个目录列表 大家一起来说一下Jbuilder9。(进者有分)
以后也不要用这样的方法让内存跑光了
你学过数据结构吗多看一看就明白了
<%
for(int i = 0; i <= 10; i++){
Thread.sleep(3000);//这里延迟3秒,当然延迟多少你可以自己估算控制。
out.println("hello word" + "<BR>");
out.flush();
}
%>
现在将10个柜子搬进去,再搬出来(呵呵,这样好傻哦)
有几种方法:
1、一个柜子搬进去,然后立刻搬出来。
2、10个柜子都搬进去,然后再搬出来。
对于方法一,就是使用flush
class A
{
public static void main(String[] args)
{
for(int i=0;i<=10;i++)
{
Thread.sleep(3000);
System.out.println("Hello World!");
System.out.flush();
}
}
}
报错:---------- javac ----------
A.java:8: unreported exception java.lang.InterruptedException; must be caught or declared to be thrown
Thread.sleep(3000);
^
1 error输出完成 (耗时 2 秒) - 正常终止
class A{
public static void main(String[] args) throws InterruptedException{
for(int i=0;i<=10;i++){
Thread.sleep(3000);
System.out.println("Hello World!");
System.out.flush();
}
}
}或者是
class A{
public static void main(String[] args){
for(int i=0;i<=10;i++){
try{
Thread.sleep(3000);
}
catch(InterruptedException e){
}
System.out.println("Hello World!");
System.out.flush();
}
}
}