1 21 22 package nu.xom.samples; 23 24 import java.io.FileOutputStream ; 25 import java.io.IOException ; 26 import java.io.OutputStream ; 27 import java.math.BigInteger ; 28 29 import nu.xom.Document; 30 import nu.xom.Element; 31 import nu.xom.Serializer; 32 33 34 45 public class FibonacciEBCDIC { 46 47 public final static char NEL = 0x85; 48 49 public static void main(String [] args) { 50 51 BigInteger low = BigInteger.ONE; 52 BigInteger high = BigInteger.ONE; 53 54 Element root = new Element("Fibonacci_Numbers"); 55 for (int i = 1; i <= 10; i++) { 56 root.appendChild(NEL+ " "); 57 Element fibonacci = new Element("fibonacci"); 58 fibonacci.appendChild(low.toString()); 59 root.appendChild(fibonacci); 60 61 BigInteger temp = high; 62 high = high.add(low); 63 low = temp; 64 } 65 root.appendChild("" + NEL); 66 Document doc = new Document(root); 67 try { 68 OutputStream out 69 = new FileOutputStream ("fibonacci_ebcdic.txt"); 70 Serializer serializer 71 = new Serializer(out, "Cp037"); 72 serializer.write(doc); 73 serializer.flush(); 74 } 75 catch (IOException ex) { 76 System.err.println(ex); 77 } 78 79 } 80 81 } | Popular Tags |