[String access] the method used to separate text strings.
Q: How can I solve this problem when the length of the field column in the database is exceeded in the project?
A common solution is string access. As the name suggests, it refers to intercepting large text data by the specified length, and storing the returned result set in the new table in the cut order. Create a type field in the new table to identify the field name in the old table corresponding to the content intercepted in the new table. The fields in the old table do not directly store the enlarged text data, but store the identifier.
Here, a tool class is provided to split text strings and return the List result set for the next step.
Public class StringUtil {/*** @ Name: getContentByList * @ Description: String cutting * @ Author: Zhang (Author) * @ Version: V1.00 (Version Number) * @ Create Date: (creation date) * @ Parameters: wholecontent: passed text string; cutcount: length of the cut string * @ Return: List: a collection of cut strings, save result set */public static List <String> getContentByList (String wholecontent, int cutcount) {List <String> list = new ArrayList <String> (); // obtain the total length of the complete content string int contentlen = w Holecontent. length (); // content truncation. Compare the content length with the content length. insert if (contentlen <cutcount) {list. add (wholecontent);} // The content length exceeds the truncation length. else {// defines and initializes the content section String contentpart = ""; // define and initialize the number of intercepted paragraphs int contentround = 0; // The starting position int begincount = 0; // determine the number of intercepted paragraphs int contentcutpart = contentlen/cutcount; int contentcutparts = contentlen % cutcount; // returns the remainder. // if the remainder is 0, the content is divisible. The content length is exactly a multiple of the truncation length. If (contentcutparts = 0) {contentround = contentcutpart;} else {contentround = contentcutpart + 1;} // The content intercepted cyclically for (int I = 1; I <= contentround; I ++) {// if it is not the last part, if (I! = Contentround) {// extract content based on the truncation length contentpart = wholecontent. substring (begincount, cutcount * I);} else {// capture the last part of content contentpart = wholecontent. substring (begincount, contentlen);} // assign a value to the starting position of the next part begincount = cutcount * I; list. add (contentpart) ;}} return list ;}}