donaldp 2002/09/26 05:46:39
Modified: event/src/java/org/apache/excalibur/util/system Linux.java
Log:
Decouple from StringUtil
Revision Changes Path
1.2 +23 -3
jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/util/system/Linux.java
Index: Linux.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/util/system/Linux.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Linux.java 25 Sep 2002 14:52:28 -0000 1.1
+++ Linux.java 26 Sep 2002 12:46:39 -0000 1.2
@@ -10,8 +10,8 @@
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Properties;
+import java.util.StringTokenizer;
import org.apache.excalibur.util.CPUParser;
-import org.apache.excalibur.util.StringUtil;
/**
* Parses the Linux environment--Uses the proc filesystem to determine all the
@@ -40,7 +40,7 @@
while( ( line = reader.readLine() ) != null )
{
- String[] args = StringUtil.split( line, ":\t" );
+ String[] args = split( line, ":\t" );
if( args.length > 1 )
{
@@ -92,6 +92,26 @@
public String cpuInfo()
{
return m_cpuInfo;
+ }
+
+ /**
+ * Splits the string on every token into an array of strings.
+ *
+ * @param string the string
+ * @param onToken the token
+ * @return the resultant array
+ */
+ private static final String[] split( final String string, final String onToken )
+ {
+ final StringTokenizer tokenizer = new StringTokenizer( string, onToken );
+ final String[] result = new String[ tokenizer.countTokens() ];
+
+ for( int i = 0; i < result.length; i++ )
+ {
+ result[ i ] = tokenizer.nextToken();
+ }
+
+ return result;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>