Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
StringBuilder.append对于大型 SQL 语句看起来很难看,并且格式化附加需要这么多时间有没有简单的方法在 Java中格式化StringBuilder/StringBuffer
StringBuilder.append
StringBuilder
StringBuffer
String.format可能有助于使代码更具可读性:
String.format
String sql = String.format("select * from %s where %s = ?;", table, field);
StringBuilder替代方案:
String sql = new StringBuilder("select * from ") .append(table) .append(" where ") .append(field) .append(" = ") .append("?") .toString();