0
私は段落をきれいに印刷するためにJavaプログラムを作成しています。段落を別のファイルにきれいに印刷
private static void printSolution(String[] words, int[] print, int n,int width) {
if (n >= 0) {
printSolution(words, print, print[n] - 1, width);
int index = print[n];
System.out.printf("%s", words[index]);
width -= words[index].length();
++index;
for (; index <= n; index++) {
System.out.printf(" %s", words[index]);
width -= words[index].length() + 1;
}
while (width > 0) {
System.out.print(" ");
width--;
}
System.out.println("|");
}
}
は今、私はそれを少し変更して、別のファイル(output.txtと)への出力を印刷したいのですが、私は:それは今あるようにようにしかし、プログラムはコンソールに出力しますそのおなじみのJavaではないので、私はこれに助けが必要です。だから、私はどのように行うか分からないのは、結果をStringに格納し、printfと同じようにフォーマットすることです。
StackOverflowの例外がスローされますので、ありがとうございました!!非常に明確な説明! – useruser1412