import java.io.*; import java.math.BigInteger; /** * * @author Elliotte Rusty Harold * @version 1.0 * */ public class FibonacciFile { public static void main(String[] args) { BigInteger low = BigInteger.ONE; BigInteger high = BigInteger.ONE; OutputStream out = null; try { out = new FileOutputStream("fibonacci.txt"); OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8"); for (int i = 1; i <= 25; i++) { writer.write(high.toString()); writer.write("\r\n"); BigInteger temp = high; high = high.add(low); low = temp; } writer.flush(); } catch (IOException ex) { System.err.println("This shouldn't happen for Latin-1!"); } finally { if (out != null) { try { out.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } }