java 控制台 暂停,是否有用于在Eclipse中停止当前控制台的键盘快捷方式?

I'm developping a Java application with a class containing main. I can start the application using Ctrl+Alt+X J subsequently the application can be re-run by hitting Alt+R T Enter to choose the menu option for the first item in the Run history.

But to stop the application, I have to click on the small red square in the console view. This is annoying, because it forces me to use the mouse, type Alt+R T Enter then re-focus the editor using the mouse again.

Eclipse being so configurable, there must be a keyboard shortcut to stop the application run in the current console I haven't found. There are an entry in Window > Preferences > Keys called Terminate and Terminate and Relaunch but no matter what binding I assign or what when conditions I set and no matter if I use the Debug perspective or not, they don't seem to fire.

Please help an Eclipse newbie avoiding the mouse :)

解决方案

Go to Preferences -> General -> Keys

Find "Terminate" Set your binding to whatever you want.

Then change "When" from "Debugging" to "Editing Java Source".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将从txt文件读取的数据以表格格式输出控制台,可以按照以下步骤实现: 1. 读取txt文件的数据 使用Java的FileReader和BufferedReader类来读取txt文件的数据,并将其存储在一个二维数组。 ```java File file = new File("data.txt"); FileReader fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); List<String[]> data = new ArrayList<>(); String line; while ((line = br.readLine()) != null) { String[] row = line.split(","); data.add(row); } br.close(); fr.close(); ``` 2. 计算每列的最大宽度 遍历二维数组,计算每列的最大宽度,以便在输出表格时设置每列的宽度。 ```java int[] columnWidths = new int[data.get(0).length]; for (String[] row : data) { for (int i = 0; i < row.length; i++) { if (row[i].length() > columnWidths[i]) { columnWidths[i] = row[i].length(); } } } ``` 3. 输出表格格式的数据到控制台 根据读取到的数据和每列的最大宽度,输出表格格式的数据到控制台。 ```java for (String[] row : data) { for (int i = 0; i < row.length; i++) { System.out.printf("%-" + columnWidths[i] + "s", row[i]); if (i < row.length - 1) { System.out.print(" "); } } System.out.println(); } ``` 在输出表格时,使用printf方法来格式化每列的宽度,其%表示格式化符号,-表示左对齐,columnWidths[i]表示宽度,s表示字符串类型。通过在格式化符号前面添加%和-,可以实现左对齐。通过在格式化符号后面添加s,可以将数据格式化为字符串类型。 这样,你就可以将从txt文件读取的数据以表格格式输出控制台了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值