Note that there are some explanatory texts on larger screens.

plurals
  1. POAre there alternatives to javax.swing.text.* for android?
    primarykey
    data
    text
    <p>I am new to Java / Android, so please be patient. Thank you in advance for your time. I'm writing a simple android app that will scan a web page's source for a=href links and return them</p> <p>I have googled for about 2 days now and can't find any definitive answer, hence my question to SO. Currently I'm using the following imports which are generated by eclipse when using Ctrl-Shift-O</p> <pre><code>import javax.swing.text.EditorKit; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLEditorKit; </code></pre> <p>The problem is that when I run my android app, it crashes on the code that uses these libs (code below).</p> <p>I need to find a way to do this without using the javax.swing imports. I have managed to figure out that android.text.html has some functionality, but not what I need.</p> <p>Are there any Android imports that I can use to do the following, or is there a way to make the javax.swing.text.* imports work with android?</p> <p>Code here :</p> <pre><code> try { URLConnection conn = params[0].openConnection(); Log.i(DEBUG_TAG, "Code fails here for the new declarations"); BufferedReader rd = new BufferedReader( new InputStreamReader(conn.getInputStream())); EditorKit kit = new HTMLEditorKit(); HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument(); kit.read(rd, doc, 0); HTMLDocument.Iterator it = doc.getIterator(HTML.Tag.A); while (it.isValid()) { SimpleAttributeSet s = (SimpleAttributeSet) it.getAttributes(); String link = (String) s.getAttribute(HTML.Attribute.HREF); if (link != null) { if (link.contains("naruto") &amp;&amp; !link.contains("http://mangastream.com")){ // find the chapter number / id and print to console String chapterNumber = link.replace("http://readms.com/r/naruto/", ""); // System.out.println("Chapter = " + chapterNumber.substring(0,3)); // System.out.println("ChapterID = " + chapterNumber.substring(4,8)); if (!registeredChapters.containsKey(chapterNumber.substring(0,3))){ registeredChapters.put(chapterNumber.substring(0,3),chapterNumber.substring(4,8)); } } } it.next(); } //appendToFile("Done with URL processing"); Log.i(DEBUG_TAG, "Current chapters / id's found: "); } catch (IOException ioe){ ioe.printStackTrace(); } catch (Exception e){ Log.i(DEBUG_TAG, e.getLocalizedMessage()); } catch (Throwable t){ Log.i(DEBUG_TAG,t.getClass().getName()); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload