Spring Street, 101/12
Postal Code: 8001
State: Washington
如何像上面的示例一样逐行分隔?
address.setAddress(MessageFormat.format(
"{0} {1} Postal Code: {2}, State: {3}",restSmeApplication.getAddress(),restSmeApplication.getStreet() != null ? restSmeApplication.getStreet(): "",restSmeApplication.getPostalCode(),restSmeApplication.getState() != null ? restSmeApplication.getStreet(): "")
);
最佳答案
\n
将为您服务-
address.setAddress(MessageFormat.format(
"{0} \n {1} Postal Code: {2}, \n State: {3}",restSmeApplication.getAddress(),restSmeApplication.getStreet() != null ? restSmeApplication.getStreet(): "",restSmeApplication.getPostalCode(),restSmeApplication.getState() != null ? restSmeApplication.getStreet(): "")
);