Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1022758 // DocumentBuilder_parse (for StackOverflow)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (46L/1K).

1  
import javax.xml.parsers.DocumentBuilder;
2  
import org.w3c.dom.Document;
3  
import org.xml.sax.SAXException;
4  
5  
static Document DocumentBuilder_parse(DocumentBuilder b, String uri) throws SAXException, IOException {
6  
  UnknownHostException lastException = null;
7  
  for (int tries = 0; tries < 2; tries++) {
8  
    try {
9  
      return b.parse(uri);
10  
    } catch (UnknownHostException e) {
11  
      lastException = e;
12  
      System.out.println("Retrying because of: " + e);
13  
      continue;
14  
    }
15  
  }
16  
  throw lastException;
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022758
Snippet name: DocumentBuilder_parse (for StackOverflow)
Eternal ID of this version: #1022758/3
Text MD5: 8d380ee9c021ee7ef813094527db4ae6
Transpilation MD5: 3d8375ac1274290e268cbf07ce2d98a6
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-06 14:17:07
Source code size: 520 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 188 / 252
Version history: 2 change(s)
Referenced in: [show references]