List of usage examples for java.net MalformedURLException getMessage
public String getMessage()
From source file:org.georchestra.security.Proxy.java
private void handleUrlParamRequest(HttpServletRequest request, HttpServletResponse response, RequestType type, String sURL) throws IOException { if (request.getRequestURI().startsWith("/sec/proxy/")) { testLegalContentType(request);/*from w ww. j av a 2 s. c om*/ URL url; try { url = new URL(sURL); } catch (MalformedURLException e) { // not an url response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); return; } if (proxyPermissions.isDenied(url) || urlIsProtected(request, url)) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "URL is not allowed."); return; } handleRequest(request, response, type, sURL, false); } else { handlePathEncodedRequests(request, response, type); } }
From source file:EBeyeClient.java
/** Ensure that a service proxy is available to call the web service. * //from w ww . j a v a 2 s. c o m * @throws ServiceException */ protected void srvProxyConnect() throws ServiceException { printDebugMessage("srvProxyConnect", "Begin", 2); if (this.srvProxy == null) { EBISearchService_Service service = new EBISearchService_ServiceLocatorExtended(); if (this.getServiceEndPoint() != null) { try { this.srvProxy = service .getEBISearchServiceHttpPort(new java.net.URL(this.getServiceEndPoint())); } catch (java.net.MalformedURLException ex) { System.err.println(ex.getMessage()); System.err.println("Warning: problem with specified endpoint URL. Default endpoint used."); this.srvProxy = service.getEBISearchServiceHttpPort(); } } else { this.srvProxy = service.getEBISearchServiceHttpPort(); } } printDebugMessage("srvProxyConnect", "End", 2); }
From source file:edu.harvard.i2b2.navigator.CRCNavigator.java
protected Control createContents(Composite parent) { // local variable to get system fonts and colors Display display = parent.getDisplay(); // todo dispose of fonts when page is closed? final Font headerFont = new Font(display, "Tahoma", 12, SWT.BOLD); final Font normalFont = new Font(display, "Tahoma", 12, SWT.NORMAL); final Font buttonFont = new Font(display, "Tahoma", 9, SWT.NORMAL); // set background color if (APP_CURRENT.equals(APP_PROD)) { backColor = display.getSystemColor(SWT.COLOR_WHITE); } else if (APP_CURRENT.equals(APP_TEST)) { backColor = display.getSystemColor(SWT.COLOR_GRAY); // default to dev } else {// w w w. j a v a 2 s . c om backColor = display.getSystemColor(SWT.COLOR_DARK_GRAY); } final Color foreColor = display.getSystemColor(SWT.COLOR_BLACK); warningColor = display.getSystemColor(SWT.COLOR_YELLOW); // final Color textColor = display.getSystemColor(SWT.COLOR_BLACK); goColor = display.getSystemColor(SWT.COLOR_GREEN); badColor = display.getSystemColor(SWT.COLOR_RED); // create top composite Composite top = new Composite(parent, SWT.NONE); FormLayout topCompositeLayout = new FormLayout(); // FormData topData=new FormData(); top.setLayout(topCompositeLayout); // GridLayout topGridLayout = new GridLayout(1, false); // topGridLayout.numColumns = 1; // topGridLayout.marginWidth = 2; // topGridLayout.marginHeight = 2; // top.setLayout(topGridLayout); // BannerC composite banner = new Composite(top, SWT.NONE); FormData bannerData = new FormData(); bannerData.left = new FormAttachment(0); bannerData.right = new FormAttachment(100); banner.setLayoutData(bannerData); // The Banner itself is configured and layout is set FormLayout bannerLayout = new FormLayout(); bannerLayout.marginWidth = 2; bannerLayout.marginHeight = 2; bannerLayout.spacing = 5; banner.setLayout(bannerLayout); // banner.setBackground(grayColor); banner.setBackground(backColor); banner.setForeground(foreColor); // add banner components and then configure layout // the label on the left is added titleLabel = new Label(banner, SWT.NO_FOCUS); titleLabel.setBackground(backColor); titleLabel.setText(msTitle); titleLabel.setFont(headerFont); titleLabel.setForeground(foreColor); // the general application area toolbar is added titleToolBar = new ToolBar(banner, SWT.FLAT); titleToolBar.setBackground(backColor); titleToolBar.setFont(headerFont); // add query mode dropdown tool item // set initial text to userLoginMode variable titleToolItem = new ToolItem(titleToolBar, SWT.DROP_DOWN); titleToolItem.setText(userLoginMode); // create menu for dropdown, create menu items, and add listeners for // dropdown tool item // hard code replace with user detail bean from webservice login values // Changed to member variable userModes [] from bean // String [] modes={"Exploration Mode","Query Mode", "Ontology Mode"}; menu = new Menu(banner.getShell(), SWT.POP_UP); // wait until after login to create menu items // addMenuItems(menu, userModes); /* * for (int i=0;i<userModes.length;i++){ MenuItem menuItem=new * MenuItem(menu,SWT.PUSH); menuItem.setText(userModes[i]); * menuItem.addSelectionListener(new SelectionAdapter() { * * @Override public void widgetSelected(SelectionEvent event) { * Auto-generated method stub //note tabFolderIndex [0] is always on * login class MenuItem selected=(MenuItem)event.widget; * //System.out.println("titleToolItem="+selected.getText()); * titleToolItem.setText(selected.getText()); * //setTabFolderIndex(menu.indexOf(selected)); * System.out.println("selected.getText="+selected.getText()); * System.out.println("menu.indexOf(selected)="+menu.indexOf(selected)); * setTabFolderIndex(menu.indexOf(selected)); * * //if (userModes[1].equals(selected.getText())){ // * setTabFolderIndex(1); //} //if * (userModes[2].equals(selected.getText())){ // setTabFolderIndex(2); * //} //if (userModes[0].equals(selected.getText())){ // * setTabFolderIndex(0); //} } * * }); } */ // add listener for toolbaritem titleToolItem.addListener(SWT.Selection, new DropDownListener(titleToolBar, menu)); titleToolItem.setEnabled(false); // Authorization label is made authorizationLabel = new Label(banner, SWT.NO_FOCUS); authorizationLabel.setBackground(backColor); authorizationLabel.setText("Awaiting Authorization..."); authorizationLabel.setAlignment(SWT.RIGHT); authorizationLabel.setFont(normalFont); authorizationLabel.setForeground(foreColor); // the staus indicator is shown statusLabel = new Label(banner, SWT.NO_FOCUS); statusLabel.setBackground(backColor); statusLabel.setText("Status:"); statusLabel.setAlignment(SWT.RIGHT); statusLabel.setFont(normalFont); statusLabel.setForeground(foreColor); statusOvalLabel = new Label(banner, SWT.NO_FOCUS); statusOvalLabel.setBackground(backColor); statusOvalLabel.setToolTipText("Click to show error log"); // statusOvalLabel.setAlignment(SWT.LEFT); // statusOvalLabel.setSize(16,16); // statusOvalLabel.setFont(normalFont); statusOvalLabel.setSize(20, 20); statusOvalLabel.setForeground(foreColor); statusOvalLabel.redraw(); statusOvalLabel.addListener(SWT.Resize, new Listener() { public void handleEvent(Event arg0) { statusOvalLabel.setSize(20, 20); statusOvalLabel.redraw(); } }); // add selection listener so that clicking on status oval label shows // error log // dialog statusOvalLabel.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event arg0) { // log.info(getNow() + "Status Listener Clicked"); Display display = statusOvalLabel.getDisplay(); final Shell shell = statusOvalLabel.getShell(); // run asyncExec so that other pending ui events finished first display.asyncExec(new Runnable() { public void run() { // LoggerD loggerD = new LoggerD(shell); // loggerD.open(); // final Shell myShell=shell; File file = new File(logFileName); URL url = null; // Convert the file object to a URL with an absolute // path try { url = file.toURL(); } catch (MalformedURLException e) { log.info(e.getMessage()); } final URL myurl = url; new HelpBrowser().run(myurl.toString(), shell); } }); // shows browser with logger in separate // showLoggerBrowser(shell).start(); } }); // add status label paint listener so that it changes color statusLabelPaintListener = new StatusLabelPaintListener(); // statusLabelPaintListener.setOvalColor(warningColor); statusOvalLabel.addPaintListener(statusLabelPaintListener); statusLabelPaintListener.setOvalColor(display.getSystemColor(SWT.COLOR_YELLOW)); statusOvalLabel.setSize(20, 20); statusOvalLabel.redraw(); // Login button is made loginButton = new Button(banner, SWT.PUSH | SWT.LEFT); loginButton.setFont(buttonFont); loginButton.setText(BUTTON_TEXT_LOGIN); // add selection listener for login Button for login/logout from banner loginButton.addSelectionListener(new SelectionAdapter() { @Override // loginAction(true) logs in, loginAction(false) logs out public void widgetSelected(SelectionEvent event) { if (loginButton.getText().equals(BUTTON_TEXT_LOGIN)) { loginAction(true); } else { loginAction(false); } } }); // right button is made final Button rightButton = new Button(banner, SWT.PUSH | SWT.LEFT); rightButton.setFont(buttonFont); rightButton.setText(" Help "); // These don't work on Windows // rightButton.setBackground(backColor); // rightButton.setForeground(foreColor); // add selection listener to show help browser in new window- separate // thread rightButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { // super.widgetSelected(arg0); final Button myButton = (Button) event.widget; // showHelpBrowser(myButton).start(); Display display = myButton.getDisplay(); final Shell myShell = myButton.getShell(); display.asyncExec(new Runnable() { public void run() { // LoggerD loggerD = new LoggerD(shell); // loggerD.open(); // final Shell myShell=shell; new HelpBrowser().run(helpURL, myShell); } }); } }); // top.pack(); // int titleLabelHeight = titleLabel.getBounds().height; // System.out.println(titleLabelHeight); // layout and configure banner components // attach titlelabel to left and align vertically with tool bar FormData titleLabelFormData = new FormData(); // titleLabelFormData.top = new FormAttachment(50, -(titleLabelHeight / // 2)); // titleLabelFormData.bottom = new FormAttachment(100); titleLabelFormData.top = new FormAttachment(titleToolBar, 0, SWT.CENTER); titleLabelFormData.left = new FormAttachment(0, 10); titleLabel.setLayoutData(titleLabelFormData); // attach left of tool bar to title label, attach top to banner // attach right to authorization label so that it will resize and remain // visible when tool bar text changes FormData titleToolBarFormData = new FormData(); titleToolBarFormData.left = new FormAttachment(titleLabel); titleToolBarFormData.top = new FormAttachment(0); titleToolBarFormData.right = new FormAttachment(authorizationLabel, 0, 0); // titleToolBarFormData.top = new FormAttachment(titleLabel, // -titleLabelHeight - 10); titleToolBar.setLayoutData(titleToolBarFormData); // attach authorization label on right to status label and center // vertically FormData authorizationLabelFormData = new FormData(); authorizationLabelFormData.right = new FormAttachment(statusLabel, -10); // authorizationLabelFormData.top = new // FormAttachment(topCanvas,-titleLabelHeight-10); authorizationLabelFormData.top = new FormAttachment(statusLabel, 0, SWT.CENTER); authorizationLabel.setLayoutData(authorizationLabelFormData); FormData statusLabelFormData = new FormData(); // statusLabelFormData.right = new FormAttachment(rightButton,0); statusLabelFormData.right = new FormAttachment(statusOvalLabel, 0); statusLabelFormData.top = new FormAttachment(statusOvalLabel, 0, SWT.CENTER); statusLabel.setLayoutData(statusLabelFormData); // attach status label on right to loginbutton and center vertically FormData statusOvalLabelFormData = new FormData(); // statusLabelFormData.right = new FormAttachment(rightButton,0); // add offset statusOvalLabelFormData.right = new FormAttachment(loginButton, -25); statusOvalLabelFormData.top = new FormAttachment(loginButton, 0, SWT.CENTER); statusOvalLabel.setLayoutData(statusOvalLabelFormData); // attach login button on right to right button and center vertically FormData loginButtonFormData = new FormData(); // loginButtonFormData.right = new FormAttachment(100,-10); loginButtonFormData.right = new FormAttachment(rightButton); loginButtonFormData.top = new FormAttachment(rightButton, 0, SWT.CENTER); // loginButtonFormData.top = new FormAttachment(50, // -(titleLabelHeight / 2) - 2); loginButton.setLayoutData(loginButtonFormData); // attach right button to right of banner and center vertically on // toolbar FormData rightButtonFormData = new FormData(); rightButtonFormData.right = new FormAttachment(100, -10); rightButtonFormData.top = new FormAttachment(titleToolBar, 0, SWT.CENTER); // rightButtonFormData.top = new FormAttachment(50, // -(titleLabelHeight / 2) - 2); rightButton.setLayoutData(rightButtonFormData); // banner.pack(); // create tab folder underneath but hide tabs // don't contruct tab items until after login tabFolder = new TabFolder(top, SWT.NONE); FormData tabFolderData = new FormData(); tabFolderData.top = new FormAttachment(banner, tabFolderOffset); tabFolderData.left = new FormAttachment(0); tabFolderData.right = new FormAttachment(100); tabFolderData.bottom = new FormAttachment(100); tabFolder.setLayoutData(tabFolderData); return top; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.java
/** * Returns the URL of the stylesheet.//from ww w . j a va2 s . c om * @return the URL of the stylesheet */ @JsxGetter public String getHref() { final BrowserVersion version = getBrowserVersion(); if (ownerNode_ != null) { final DomNode node = ownerNode_.getDomNodeOrDie(); if (node instanceof HtmlLink) { // <link rel="stylesheet" type="text/css" href="..." /> final HtmlLink link = (HtmlLink) node; final HtmlPage page = (HtmlPage) link.getPage(); final String href = link.getHrefAttribute(); if ("".equals(href) && version.hasFeature(STYLESHEET_HREF_EMPTY_IS_NULL)) { return null; } // Expand relative URLs. try { final URL url = page.getFullyQualifiedUrl(href); return url.toExternalForm(); } catch (final MalformedURLException e) { // Log the error and fall through to the return values below. LOG.warn(e.getMessage(), e); } } } return null; }
From source file:se.vgregion.service.barium.BariumRestClientImpl.java
@Override public InputStream doGetFileStream(String objectId) throws BariumException { URL url = null;/*from ww w. j ava 2s .co m*/ try { url = new URL(this.apiLocation + "/Objects/" + objectId + "/File"); } catch (MalformedURLException e) { throw new RuntimeException(e); } try { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); if (ticket != null) { conn.setRequestProperty("ticket", ticket); } else { this.connect(); conn.setRequestProperty("ticket", ticket); } conn.setRequestMethod("GET"); conn.setRequestProperty("charset", "utf-8"); conn.setDoOutput(true); conn.setDoInput(true); return conn.getInputStream(); } catch (IOException e) { LOGGER.error(e.getMessage(), e); throw new BariumException("Filed to get filestream. ", e); } }
From source file:de.matzefratze123.heavyspleef.util.Updater.java
public void query() { URL url;/*from ww w . j a v a 2 s .c o m*/ try { url = new URL(API_HOST + API_QUERY + PROJECT_ID); } catch (MalformedURLException e) { e.printStackTrace(); return; } try { URLConnection conn = url.openConnection(); conn.setConnectTimeout(6000); conn.addRequestProperty("User-Agent", "HeavySpleef-Updater (by matzefratze123)"); final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); String query = reader.readLine(); JSONArray array = (JSONArray) JSONValue.parse(query); String version = null; if (array.size() > 0) { // Get the newest file's details JSONObject latest = (JSONObject) array.get(array.size() - 1); fileTitle = (String) latest.get(API_TITLE_VALUE); fileName = (String) latest.get(API_NAME_VALUE); downloadUrl = (String) latest.get(API_LINK_VALUE); String[] parts = fileTitle.split(" v"); if (parts.length >= 2) { version = parts[1]; } checkVersions(version); done = true; } } catch (IOException e) { Logger.severe("Failed querying the curseforge api: " + e.getMessage()); e.printStackTrace(); } }
From source file:ti.modules.titanium.network.TiHTTPClient.java
public void open(String method, String url) { Log.d(TAG, "open request method=" + method + " url=" + url, Log.DEBUG_MODE); if (url == null) { Log.e(TAG, "Unable to open a null URL"); throw new IllegalArgumentException("URL cannot be null"); }/*from w w w . j a v a2 s . c o m*/ // if the url is not prepended with either http or // https, then default to http and prepend the protocol // to the url String lowerCaseUrl = url.toLowerCase(); if (!lowerCaseUrl.startsWith("http://") && !lowerCaseUrl.startsWith("https://")) { url = "http://" + url; } if (autoEncodeUrl) { this.uri = TiUrl.getCleanUri(url); } else { this.uri = Uri.parse(url); } // If the original url does not contain any // escaped query string (i.e., does not look // pre-encoded), go ahead and reset it to the // clean uri. Else keep it as is so the user's // escaping stays in effect. The users are on their own // at that point. if (autoEncodeUrl && !url.matches(".*\\?.*\\%\\d\\d.*$")) { this.url = this.uri.toString(); } else { this.url = url; } redirectedLocation = null; this.method = method; String hostString = uri.getHost(); int port = PROTOCOL_DEFAULT_PORT; // The Android Uri doesn't seem to handle user ids with at-signs (@) in them // properly, even if the @ is escaped. It will set the host (uri.getHost()) to // the part of the user name after the @. For example, this Uri would get // the host set to appcelerator.com when it should be mickey.com: // http://testuser@appcelerator.com:password@mickey.com/xx // ... even if that first one is escaped to ... // http://testuser%40appcelerator.com:password@mickey.com/xx // Tests show that Java URL handles it properly, however. So revert to using Java URL.getHost() // if we see that the Uri.getUserInfo has an at-sign in it. // Also, uri.getPort() will throw an exception as it will try to parse what it thinks is the port // part of the Uri (":password....") as an int. So in this case we'll get the port number // as well from Java URL. See Lighthouse ticket 2150. if (uri.getUserInfo() != null && uri.getUserInfo().contains("@")) { URL javaUrl; try { javaUrl = new URL(uri.toString()); hostString = javaUrl.getHost(); port = javaUrl.getPort(); } catch (MalformedURLException e) { Log.e(TAG, "Error attempting to derive Java url from uri: " + e.getMessage(), e); } } else { port = uri.getPort(); } Log.d(TAG, "Instantiating host with hostString='" + hostString + "', port='" + port + "', scheme='" + uri.getScheme() + "'", Log.DEBUG_MODE); host = new HttpHost(hostString, port, uri.getScheme()); if (uri.getUserInfo() != null) { credentials = new UsernamePasswordCredentials(uri.getUserInfo()); } if (credentials == null) { String userName = ((HTTPClientProxy) proxy).getUsername(); String password = ((HTTPClientProxy) proxy).getPassword(); String domain = ((HTTPClientProxy) proxy).getDomain(); if (domain != null) { password = (password == null) ? "" : password; credentials = new NTCredentials(userName, password, TiPlatformHelper.getMobileId(), domain); } else { if (userName != null) { password = (password == null) ? "" : password; credentials = new UsernamePasswordCredentials(userName, password); } } } setReadyState(READY_STATE_OPENED); setRequestHeader("User-Agent", TITANIUM_USER_AGENT); // Causes Auth to Fail with twitter and other size apparently block X- as well // Ticket #729, ignore twitter for now if (!hostString.contains("twitter.com")) { setRequestHeader("X-Requested-With", "XMLHttpRequest"); } else { Log.i(TAG, "Twitter: not sending X-Requested-With header", Log.DEBUG_MODE); } }
From source file:org.eclipse.cft.server.core.internal.client.CloudFoundryServerBehaviour.java
/** * Creates a new client to the specified server URL using the given * credentials. This does NOT connect the client to the server, nor does it * set the client as the session client for the server behaviour. The * session client is set indirectly via {@link #connect(IProgressMonitor)} * @param serverURL server to connect to. Must NOT be null. * @param credentials must not be null./*ww w . jav a2s . co m*/ * @param cloudSpace optional. Can be null, as a client can be created * without specifying an org/space (e.g. a client can be created for the * purpose of looking up all the orgs/spaces in a server) * @param selfSigned true if connecting to a server with self signed * certificate. False otherwise * @return non-null client. * @throws CoreException if failed to create client. */ private static CloudFoundryOperations createClientWithCredentials(String serverURL, CloudCredentials credentials, CloudFoundrySpace cloudSpace, boolean selfSigned) throws CoreException { URL url; try { url = new URL(serverURL); int port = url.getPort(); if (port == -1) { port = url.getDefaultPort(); } // If no cloud space is specified, use appropriate client factory // API to create a non-space client // NOTE that using a space API with null org and space will result // in errors as that API will // expect valid org and space values. return cloudSpace != null ? CloudFoundryPlugin.getCloudFoundryClientFactory().getCloudFoundryOperations(credentials, url, cloudSpace.getOrgName(), cloudSpace.getSpaceName(), selfSigned) : CloudFoundryPlugin.getCloudFoundryClientFactory().getCloudFoundryOperations(credentials, url, selfSigned); } catch (MalformedURLException e) { throw new CoreException(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID, "The server url " + serverURL + " is invalid: " + e.getMessage(), e)); //$NON-NLS-1$ //$NON-NLS-2$ } }
From source file:com.denimgroup.threadfix.service.defects.utils.RestUtilsImpl.java
@Nonnull private InputStream postUrl(String urlString, String data, String username, String password, String contentType) {//from w w w . j a v a 2 s .c om URL url; try { url = new URL(urlString); } catch (MalformedURLException e) { LOG.warn("URL used for POST was bad: '" + urlString + "'"); throw new RestUrlException(e, "Received a malformed server URL."); } HttpURLConnection httpConnection = null; OutputStreamWriter outputWriter = null; try { if (proxyService == null) { httpConnection = (HttpURLConnection) url.openConnection(); } else { httpConnection = proxyService.getConnectionWithProxyConfig(url, classToProxy); } setupAuthorization(httpConnection, username, password); httpConnection.addRequestProperty("Content-Type", contentType); httpConnection.addRequestProperty("Accept", contentType); httpConnection.setDoOutput(true); outputWriter = new OutputStreamWriter(httpConnection.getOutputStream()); outputWriter.write(data); outputWriter.flush(); InputStream is = httpConnection.getInputStream(); return is; } catch (IOException e) { LOG.warn("IOException encountered trying to post to URL with message: " + e.getMessage()); if (httpConnection == null) { LOG.warn( "HTTP connection was null so we cannot do further debugging of why the HTTP request failed"); } else { try { InputStream errorStream = httpConnection.getErrorStream(); if (errorStream == null) { LOG.warn("Error stream from HTTP connection was null"); } else { LOG.warn( "Error stream from HTTP connection was not null. Attempting to get response text."); setPostErrorResponse(IOUtils.toString(errorStream)); LOG.warn("Error text in response was '" + getPostErrorResponse() + "'"); throw new RestIOException(e, getPostErrorResponse(), "Unable to get response from server. Error text was: " + getPostErrorResponse(), getStatusCode(httpConnection)); } } catch (IOException e2) { LOG.warn("IOException encountered trying to read the reason for the previous IOException: " + e2.getMessage(), e2); throw new RestIOException(e2, "Unable to read response from server." + e2.getMessage(), getStatusCode(httpConnection)); } } throw new RestIOException(e, "Unable to read response from server." + e.toString()); } finally { if (outputWriter != null) { try { outputWriter.close(); } catch (IOException e) { LOG.warn("Failed to close output stream in postUrl.", e); } } } }
From source file:com.penguineering.cleanuri.sites.reichelt.ReicheltExtractor.java
@Override public Map<Metakey, String> extractMetadata(URI uri) throws ExtractorException { if (uri == null) throw new NullPointerException("URI argument must not be null!"); URL url;/*from w ww. j a v a 2s . c o m*/ try { url = uri.toURL(); } catch (MalformedURLException e) { throw new IllegalArgumentException("The provided URI is not a URL!"); } Map<Metakey, String> meta = new HashMap<Metakey, String>(); try { final URLConnection con = url.openConnection(); LineNumberReader reader = null; try { reader = new LineNumberReader(new InputStreamReader(con.getInputStream())); String line; while ((line = reader.readLine()) != null) { if (!line.contains("<h2>")) continue; // h2 int h2_idx = line.indexOf("h2"); // Doppelpunkte int col_idx = line.indexOf("<span> :: <span"); final String art_id = line.substring(h2_idx + 3, col_idx); meta.put(Metakey.ID, html2oUTF8(art_id).trim()); int span_idx = line.indexOf("</span>"); final String art_name = line.substring(col_idx + 32, span_idx); meta.put(Metakey.NAME, html2oUTF8(art_name).trim()); break; } return meta; } finally { if (reader != null) reader.close(); } } catch (IOException e) { throw new ExtractorException("I/O exception during extraction: " + e.getMessage(), e, uri); } }