1 53 54 package org.swixml.converters; 55 56 import java.util.StringTokenizer ; 57 58 64 public final class Util { 65 70 static int[] ia( StringTokenizer st ) { 71 int size = st != null ? st.countTokens() : 0; 72 int[] a = new int[size]; 73 int i = 0; 74 while (st != null && st.hasMoreTokens()) { 75 try { 76 a[i] = Integer.parseInt( st.nextToken().trim() ); 77 i++; 78 } catch (NumberFormatException e) { 79 } 81 } 82 int[] b = new int[i]; 83 System.arraycopy( a, 0, b, 0, i ); 84 return b; 85 } 86 87 92 static double[] da( StringTokenizer st ) { 93 int size = st != null ? st.countTokens() : 0; 94 double[] a = new double[size]; 95 int i = 0; 96 while (st != null && st.hasMoreTokens()) { 97 try { 98 a[i] = Double.parseDouble( st.nextToken().trim() ); 99 i++; 100 } catch (NumberFormatException e) { 101 } 103 } 104 double[] b = new double[i]; 105 System.arraycopy( a, 0, b, 0, i ); 106 return b; 107 } 108 114 public static final String capitalize( final String s ) { 115 String cs = null; 116 if (s != null && 0 < s.length()) { 117 final char[] chars = s.toCharArray(); 118 chars[0] = Character.toUpperCase( chars[0] ); 119 cs = new String ( chars ); 120 } 121 return cs; 122 } 123 } 124 | Popular Tags |