Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting array to File in Java
    primarykey
    data
    text
    <p>Edit of my code and question, I changed the BufferedWriter to class object and initialized it </p> <pre><code>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 &lt; frequencies.length; i++, j += 2 ) { int low = signal[ j ] &amp; 0xFF; int high = signal[ j + 1 ] &amp; 0xFF; frequencies[ i ] = low | ( high &lt;&lt; 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(); } } </code></pre> <p>Now it does not print anything to the file , it just create an empty frequencie.txt file</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload