私のコードと質問の編集、BufferedWriterをクラスオブジェクトに変更して初期化しました
public static String filename = "frequencies.txt";
public static BufferedWriter bufferedWriter;
{
try
{
bufferedWriter = new BufferedWriter( new FileWriter( filename ) );
}
catch ( IOException e )
{
e.printStackTrace();
}
}
private void plot_Frequencies ( final ITraceDetails msg )
{
byte[] signal = msg.getFieldValue( "_Decoder Message" ).data();
int[] frequencies = new int[ 32 ];
try
{
for ( int i = 0, j = 29; i < frequencies.length; i++, j += 2 )
{
int low = signal[ j ] & 0xFF;
int high = signal[ j + 1 ] & 0xFF;
frequencies[ i ] = low | ( high << 8 );
this.Frequencies.add( createGTSXYDataItem( msg.getMsgIndex(), msg.getMsgIndex(), msg.getExtendedMid(), frequencies[ i ] ), false );
}
write_Frequencies( frequencies, band_number, bufferedWriter );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
private void write_Frequencies ( final int[] frequencies, final int band, final BufferedWriter writer ) throws IOException
{
try
{
// Start writing to the output stream
System.out.print( Arrays.toString( frequencies ) );
System.out.print( "\n" );
writer.write( "Hello World" );
writer.write( Arrays.toString( frequencies ) );
writer.newLine();
}
catch ( FileNotFoundException ex )
{
ex.printStackTrace();
}
catch ( IOException ex )
{
ex.printStackTrace();
}
}
ファイルに何も出力せず、空の frequencie.txt ファイルを作成するだけです。