나는 그런 클래스 다른 개발자가 작성한 :클래스 본문의 중괄호는 무엇을합니까?
public class ManifestFile implements Serializable {
private final static DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
private final static XPathFactory xPathFactory = XPathFactory.newInstance();
private final static DateFormat YYYYMMDD = new SimpleDateFormat("yyyyMMdd");
private final String uuid;
private final Set<File> attachments = new LinkedHashSet<File>();
private final transient ApplicationContext applicationContext = JavaService.INSTANCE.getApplicationContext();
private final transient File attachmentDirectory;
private final Date processAfter = new Date(System.currentTimeMillis() + 3 * 1000 * 60);
{
try {
documentBuilderFactory.setNamespaceAware(true);
final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new StreamSource(getClass().getResourceAsStream("/StrategicEmail5.xsd")));
documentBuilderFactory.setSchema(schema);
documentBuilderFactory.setValidating(true);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
나는이 부분에 의해 놀랜다 :
{
try {
documentBuilderFactory.setNamespaceAware(true);
final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new StreamSource(getClass().getResourceAsStream("/StrategicEmail5.xsd")));
documentBuilderFactory.setSchema(schema);
documentBuilderFactory.setValidating(true);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
누군가가 설명해 주 시겠어요가 유효이 코드와 사용의 장점은 {} 무엇인가 어떤 방법의 몸 밖에서?
대단히 감사합니다. 당신과 정답을 제공 한 다른 사람들에게. –