나는 운동을 하 고 있는 활동을 위한 Java 프로그래밍은 물론,이 질문으로 그렇:
쓰기 방식이라는 printTree 출력하는 파일에 삼각형의 별표에 따라 높이 값을 전달하는 절차이다. 이 테스트 방식에 주요 방법입니다.
- E.g. 삼각형의 높이 3 해야 라는 파일에 출력을 file14:
난 그냥 확인을 작성하는 방법을 반환하는 파일에서 주요 방법입니다. 고 싶을 최소화를 가져오는 다른 java.io 방법을 고객께서는 FileWriter,하지만 어떤 도움을 평가,감사합니다.
import java.io.PrintWriter;
public class OutputToFile14 {
public static void main(String[] args) throws Exception{
//Creating PrintWriter
PrintWriter output = new PrintWriter("file14.txt");
//writing method output to file
output.write(printTree(4));
//saving file
output.close();
}
public static void printTree (int height) throws IOException{
for (int i = 0; i < height; i++) {
for (int j = 0; j < height; j++) {
if (j < i) {
System.out.print("*");
}
}
System.out.println();
}
}
}