1 30 31 32 package org.hsqldb.lib.java; 33 34 import java.io.File ; 35 import java.io.FileNotFoundException ; 36 import java.io.FileOutputStream ; 37 import java.io.IOException ; 38 import java.io.OutputStream ; 39 import java.io.PrintStream ; 40 import java.io.PrintWriter ; 41 import java.math.BigDecimal ; 42 import java.math.BigInteger ; 43 import java.sql.DriverManager ; 44 import java.util.Properties ; 45 import java.text.Collator ; 46 import java.io.RandomAccessFile ; 47 48 51 57 public class JavaSystem { 58 59 public static int gcFrequency; 61 public static int memoryRecords; 62 63 public static void gc() { 65 66 if ((gcFrequency > 0) && (memoryRecords > gcFrequency)) { 67 memoryRecords = 0; 68 69 System.gc(); 70 } 71 } 72 73 76 public static int CompareIngnoreCase(String a, String b) { 77 78 82 83 return a.compareToIgnoreCase(b); 85 86 } 88 89 public static double parseDouble(String s) { 90 91 95 96 return Double.parseDouble(s); 98 99 } 101 102 public static BigInteger getUnscaledValue(BigDecimal o) { 103 104 109 110 return o.unscaledValue(); 112 113 } 115 116 public static void setLogToSystem(boolean value) { 117 118 126 127 try { 129 PrintWriter newPrintWriter = (value) ? new PrintWriter (System.out) 130 : null; 131 132 DriverManager.setLogWriter(newPrintWriter); 133 } catch (Exception e) {} 134 135 } 137 138 public static void deleteOnExit(File f) { 139 140 143 144 f.deleteOnExit(); 146 147 } 149 150 public static void saveProperties(Properties props, String name, 151 OutputStream os) throws IOException { 152 153 157 158 props.store(os, name); 160 161 } 163 164 public static void runFinalizers() { 165 166 170 171 } 173 174 public static boolean createNewFile(File file) { 175 176 179 180 try { 182 return file.createNewFile(); 183 } catch (IOException e) {} 184 185 return false; 186 187 } 189 190 public static void setRAFileLength(RandomAccessFile raFile, 191 long length) throws IOException { 192 195 196 raFile.setLength(length); 198 } 200 } 201 | Popular Tags |