Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区 » 实战错误讨论  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
话题被移动
该话题已被移动 - littledeer1974 , 2004-11-01 11:02
如果您尚不清楚该话题被移动的原因,请参考论坛规则以及本版公告或者联系本版版主。
作者 请教:LINUX下Console输出信息的清屏命令
xxg0621





发贴: 9
积分: 0
于 2004-11-01 10:41 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我现在要用java做一个类似与Fdisk的dos下的菜单式界面,但是我不知道在向屏幕输出信息之前如何清屏。那位大哥知道?我不胜感激!我的程序是要在linux系统下运行的 .

littledeer1974 edited on 2004-11-01 10:56

作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:xxg0621]
littledeer1974

Garbage Collector

CJSDN高级会员


发贴: 1517
积分: 122
于 2004-11-01 11:02 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
clear
相当于DOS的CLS
http://www.yesky.com/20030306/1655486_11.shtml
{这个我想应该自己能查到的吧}



Surround yourself with people who are open to change

作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:littledeer1974]
xxg0621





发贴: 9
积分: 0
于 2004-11-01 18:59 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
怎么加到java代码里面呀?大哥

比如说我要输出字符串
pringln("Hello");
println("How are you!");

我怎么让Linux 的shell在显示输出字符串Hello之前清屏?



作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:xxg0621]
littledeer1974

Garbage Collector

CJSDN高级会员


发贴: 1517
积分: 122
于 2004-11-01 21:24 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
xxg0621 wrote:
怎么加到java代码里面呀?大哥

比如说我要输出字符串
pringln("Hello");
println("How are you!");

我怎么让Linux 的shell在显示输出字符串Hello之前清屏?


你在你的第一贴里没有问这个呀,老大,这是谁的问题呢? 你自己得首先问清楚对不对呢?



Surround yourself with people who are open to change

作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:littledeer1974]
ditty

负资产小资

CJSDN高级会员


发贴: 1038
积分: 143
于 2004-11-02 08:29 user profilesend a private message to usersend email to dittysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

Runtime runtime = Runtime.getRuntime();
runtime.exec("clear");
System.out.println("Hello");
System.out.println("How are you!");



内忧外患的时代,洗心革面,阿咪豆腐~
作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:ditty]
kavinwang

现实版流氓兔

版主


发贴: 529
积分: 38
于 2004-11-02 09:05 user profilesend a private message to usersend email to kavinwangsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
ditty wrote:

Runtime runtime = Runtime.getRuntime();
runtime.exec("clear");
System.out.println("Hello");
System.out.println("How are you!");



你试过有用吗?



作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:xxg0621]
littledeer1974

Garbage Collector

CJSDN高级会员


发贴: 1517
积分: 122
于 2004-11-02 09:13 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I tried this in Linux
runs well

Smile


import java.io.IOException;
public class test {
public static void main(String[] args) {
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("clear");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Hello");
System.out.println("How are you!");
}
}



Surround yourself with people who are open to change

作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:littledeer1974]
xxg0621





发贴: 9
积分: 0
于 2004-11-13 17:08 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
谢谢!
为什么同样的程序把clear命令改成windows下的cls命令却不能在windows下运行?
请指教!



作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:xxg0621]
qingbo777

轻薄



发贴: 106
积分: 0
于 2004-11-13 17:42 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你试试在windows运行里打cls能直接运行么?
这就是你的程序在windows下不能运行的原因.
试着改成"cmd /k cls"
应该就可以了.



总想让自己变的帅一点,
却发现离这个目标越来越远.
作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:qingbo777]
xxg0621





发贴: 9
积分: 0
于 2004-11-14 14:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
改成"cmd /k cls"就更不行了,我的程序如下,运行之后就会发生IOException,大侠帮我分析分析:

import java.io.*;
public class cls {
public static void main(String[] args) {
//clear the screen(for Windows System)
try
{
Process process = Runtime.getRuntime().exec ("cls");
InputStreamReader ir=new InputStreamReader(process.getInputStream());
LineNumberReader in = new LineNumberReader (ir);
String line;
while ((line = in.readLine ()) != null)
System.out.println(line);
}
catch (Exception e) {
System.err.println ("IOException " + e.getMessage());
}
System.out.println("Hello");
System.out.println("How are you!");
}
}



作者 Re:请教:LINUX下Console输出信息的清屏命令 [Re:xxg0621]
qingbo777

轻薄



发贴: 106
积分: 0
于 2004-11-15 12:04 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
sorry,我记错了.应该是"cmd /c cls".
另外,cmd是win2000或xp下的.如果是win98或nt的话,要改成command.
你可以用System.getProperty("os.name")来获取当前操作系统的名称,然后作进一步的选择.



总想让自己变的帅一点,
却发现离这个目标越来越远.

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923