java - 将Java程序的输出结果保存到文件中

标签 java ubuntu save output logfile

我想在我的 Ubuntu VPS 上运行所谓的Vanity Generator来生成自定义地址。问题是:您使用 java genacc 启动程序,之后您必须输入一个目标(您想要在生成的地址中使用的自定义字符串)。因此,程序启动后,它会要求输入字符串,然后您不能使用 CustomString > logfile.txt 因为脚本会认为我想要生成一个包含 CustomString > logfile.txt 的地址 但这是行不通的。

1) download http://blockexplore.in/static/nemGenVanity.zip

2) unzip to your desktop

3) open a command prompt and type cd Desktop/nemGenVanity

4) then type java genacc

5) pick the target that you would like in your address

Three letter words should come really fast, four letter still quickly, five letter words might take a some minutes, six letter words might take some hours, and seven letter words will take days.

README.txt

To Run: java genacc

To compile from source: javac genacc.java

Creates accounts until it finds your target string. If someone has the > private key, they have your account. So keep it safe.

General remark on addresses:

1) All mainnet addresses start with a 'N' followed by 'A', 'B', 'C', or 'D'. So you won't find addresses that start with 'NE' or 'NN' or 'N4'.

2) The digits '0', '1', '8' and '9' are not part of base32 and therefore will not appear in any address.

最佳答案

从描述中尚不清楚您到底如何使用它,因此我将介绍两种可能的情况。

情况 1:Java 程序 genacc 从标准输入读取。也就是说,如果您只是以交互方式运行它,您将输入如下内容

java genacc
MyCustomAddress

后跟一个 control-D 字符(表示从终端输入的“文件结束”),其中 MyCustomAddress 是程序的一行输入。

如果是这种情况,只需使用命令中的 > 字符将其标准输出写入日志文件,因此:

java genacc > logfile.txt
MyCustomAddress

情况 2:如果 MyCustomAddress 是要传递到 Java 程序中的命令行参数(因此,在其 main(String [] args) 元素中 [0] ),像这样交互:

java genacc MyCustomAddress

然后只需将重定向添加到命令末尾

java genacc MyCustomAddress > logfile.txt

程序不会“看到”> 或后面的文件名。这些由 shell 解释。在内部,shell 在调用 java 之前将标准输出文件描述符分配给 logfile.txt,仅向其传递 MyCustomAddress 参数。

关于java - 将Java程序的输出结果保存到文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30042261/

相关文章:

java - Eclipse 程序未运行?

java - 我们可以在不使用 Java 中的 return 的情况下为传入参数的对象赋值吗?

video - 保存 UIImagePicker 视频

bash - 如何比较cpu串口是否正确

c# 在每 200 个循环后保存 Streamwriter 而不关闭

forms - 如何告诉 Play Framework 2 和 Ebean 保存空字段?

java - 获取旋转矩形的角

java - 组合父布局的垂直 ScrollView 和viewpager的内容

ubuntu - 在 "dpkg --get-selections"和基于 ubuntu 之间获得差异?

在 Ubuntu 上从 pypi 安装软件包时出现 Python Pycharm 错误