Java 如何在给定3个字符串数组的情况下创建3列文本文件

Java 如何在给定3个字符串数组的情况下创建3列文本文件,java,text-files,Java,Text Files,我试图用java编程创建一个格式化的文本文件。基本上,我有3个字符串类型数组,每个数组应该是一列 例: 一个简单的一次性方法是 1.打开要将数据写入的文件的FileOutputStream。 2.使用String.format()获取每列具有指定宽度的行。 3.FileOutStream.write(byte[])方法打印#2中的字符串。for(int=0;i)捕获类及其对象中的数据。使用Math.max方法计算stringMaxLength String column1[]; String c

我试图用java编程创建一个格式化的文本文件。基本上,我有3个字符串类型数组,每个数组应该是一列

例:

一个简单的一次性方法是 1.打开要将数据写入的文件的FileOutputStream。 2.使用
String.format()
获取每列具有指定宽度的行。
3.FileOutStream.write(byte[])方法打印#2中的字符串。

for(int=0;i)捕获类及其对象中的数据。使用Math.max方法计算stringMaxLength
String column1[];
String column2[];
String column3[];

void ArraysToTextFile(String FilePath)
{
    // code here
}
for(int =0; i<stringMaxLength; i++){
   if(column1.length<stringMaxLength)
      System.out.print(column1[i]);
   else System.out.print(0);
   if(column2.length<stringMaxLength)
      System.out.print(column2[i]);
   else System.out.print(0);
   if(column3.length<stringMaxLength)
      System.out.print(column3[i]);
   else System.out.print(0);

   System.out.println();
}