Java function question
<p>Alright I am very new to Java and am trying to develop an application to teach myself how to use the language.</p>

<p>I have been copying and pasting the same few lines of code all over, and I know that there is a way to consolidate this into a function, but cannot quite figure it out.</p>

<pre><code> FileOutputStream fout4 = openFileOutput("building1hourly.txt", MODE_WORLD_READABLE);
 OutputStreamWriter osw4 = new OutputStreamWriter(fout4);
 osw4.write("" +iHourlyAfter);
 osw4.flush();
 osw4.close();
</code></pre>

<p>Now isn't there some type of way I could do something like this</p>

<pre><code>public void writerFunction("What to write to file", "name stream", "name writer", "MODE"){insert above code here}
</code></pre>
