This is the second time I have read this book, I have studied xml,javascript and learned the JAVA core technology.
In which in-depth study of Java many mechanisms.
Looking back at the search engine this book, I feel better than the first time.
This is the code that can run,
If you want to customize, then put str1= "";
The middle of the string modification.
Java code:
Package com;
Import Java.util.HashMap;
Import Org.xml.sax.HandlerBase;
public class Replace {
public static string replace (string line) {
Create a HashMap store the correspondence between full-width and half-width characters
HashMap map = new HashMap ();
Map.put (",", ",");
Map.put (". ", ".");
Map.put ("(", "<");
Map.put ("", ">");
Map.put ("|", "|");
Map.put ("", "<");
Map.put ("" "," > ");
Map.put ("[", "[");
Map.put ("]", "]");
Map.put ("? ", "?");
Map.put ("" "," \ "");
Map.put (":", ":");
Map.put ("﹑", ",");
Map.put ("(", "(");
Map.put (")", ")");
Map.put ("" "," [");
Map.put ("" ","] ");
Map.put ("-", "-");
Map.put (" ̄", "~");
Map.put ("! ", "!");
Map.put ("'", "'");
Map.put ("1", "1");
Map.put ("2", "2");
Map.put ("3", "3");
Map.put ("4", "4");
Map.put ("5", "5");
Map.put ("6", "6");
Map.put ("7", "7");
Map.put ("8", "8");
Map.put ("9", "9");
int length = Line.length ();
for (int i = 0; i < length; i++) {
String Charat = line.substring (i, i + 1);
if (Map.get (charat) = null) {
line = Line.replace (Charat, (String) Map.get (Charat));
}
}
return line;
}
public static void Main (string[] args) {
TODO auto-generated Method Stub
Replace a = new replace ();
String str1 = "1111";
String str2;
STR2 = replace (STR1);
System.out.println ("Converted is:" + str2);
}
}
Convert full-width half-width (operational) via Lucnene for text preprocessing