1 28 29 package org.objectweb.ccm.visitorIDL3.common; 30 31 42 43 public class PrintStreamManager 44 { 45 51 54 private String directory_; 55 56 59 private org.objectweb.ccm.util.Table streams_; 60 61 67 70 public 71 PrintStreamManager() 72 { 73 directory_ = ""; 74 streams_ = new org.objectweb.ccm.util.Table(); 75 } 76 77 83 91 public PrintStream 92 create(String name, String tabular) 93 { 94 PrintStream ps = null; 95 java.io.File file = new java.io.File (directory_); 96 try 97 { 98 file.mkdirs(); 99 if (name.equals("stdout")) 102 ps = new PrintStream(System.out,tabular, "stdout", this); 103 else 104 ps = new PrintStream( 105 new java.io.PrintStream (new java.io.FileOutputStream (directory_ + name)), 106 tabular, name, this); 107 } 108 catch (java.io.FileNotFoundException e) 109 { 110 throw new Error ("File " + directory_ + name + " not found."); 111 } 112 catch (java.lang.SecurityException e) 113 { 114 throw new Error ("Directory " + directory_ + " can\'t be created."); 115 } 116 streams_.put(name, ps); 117 return ps; 118 } 119 120 125 public void 126 close(String name) 127 { 128 PrintStream ps = (PrintStream)streams_.remove(name); 129 if (!name.equals("stdout")) 130 { 131 ps.close(); 132 } 133 } 134 135 142 public void 143 setDirectory(String directory) 144 { 145 directory_ = directory; 146 } 147 148 155 public PrintStream 156 getPrintStream(String name) 157 { 158 return (PrintStream)streams_.get(name); 159 } 160 } 161 | Popular Tags |