Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
StripQualifiers.java
Upload User: zhuyoum
Upload Date: 2007-07-08
Package Size: 1377k
Code Size: 1k
Category:
E-Books
Development Platform:
HTML/CSS
- //: com:bruceeckel:util:StripQualifiers.java
- package com.bruceeckel.util;
- import java.io.*;
- public class StripQualifiers {
- private StreamTokenizer st;
- public StripQualifiers(String qualified) {
- st = new StreamTokenizer(
- new StringReader(qualified));
- st.ordinaryChar(' '); // Keep the spaces
- }
- public String getNext() {
- String s = null;
- try {
- int token = st.nextToken();
- if(token != StreamTokenizer.TT_EOF) {
- switch(st.ttype) {
- case StreamTokenizer.TT_EOL:
- s = null;
- break;
- case StreamTokenizer.TT_NUMBER:
- s = Double.toString(st.nval);
- break;
- case StreamTokenizer.TT_WORD:
- s = new String(st.sval);
- break;
- default: // single character in ttype
- s = String.valueOf((char)st.ttype);
- }
- }
- } catch(IOException e) {
- System.err.println("Error fetching token");
- }
- return s;
- }
- public static String strip(String qualified) {
- StripQualifiers sq =
- new StripQualifiers(qualified);
- String s = "", si;
- while((si = sq.getNext()) != null) {
- int lastDot = si.lastIndexOf('.');
- if(lastDot != -1)
- si = si.substring(lastDot + 1);
- s += si;
- }
- return s;
- }
- } ///:~