[AppleScript] 纯文本查看 复制代码 public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
TreeSet<Integer> ts = new TreeSet<>(new Comparator<Integer>() {
@Override
public int compare(Integer lhs, Integer rhs) {
return rhs.compareTo(lhs);
}
});
while (ts.size() < 10) {
int num = (int) (Math.random() * 100 + 1);
if ((num & 1) != 0 && num % 3 == 0) {
ts.add(num);
}
}
StringBuilder sb = new StringBuilder();
int index = 0;
for (Integer value : ts) {
index++;
if (index != ts.size()) {
sb.append(value + ",");
} else {
sb.append(value);
}
}
BufferedWriter bw = new BufferedWriter(new FileWriter("num.txt"));
bw.write(sb.toString());
bw.close();
} |