html - Java search string for certain wordgroups -


I have this code, which is working fine, which is giving me the source code of a website:

  Package Quellenpackage; Import java.net.URL; Import java.io * *; Public class Quellcode throws IOException {/ ** * @ Ultimate Argus * / Public Static Zero Main (String [] Args) {// TODO Auto generated method stub final string meineURL = "http://www.onvista.de/ Aktien / Technische-kennzahlen / Aareal-bank- Aktie-DE0005408116 "; Url url = new url (mien url); InputStreamReader isr = New InputStreamReader (url.openConnection (). GetInputStream ()); Buffed reader br = new buffed reader (ISR); // Read full content String Line = ""; String code = ""; While ((line = br.readline ()) = null) {code + = row + "\ r \ n"; } // open reader br.close (); Isr.close (); // Give the page content. System.out.println (code); }   

Right now, it shows me all the code on the page, but I only want a certain part. This part must be exactly between the exact signals "Start:" and "ende" . So I need something that searches for the code for the "start up:" section and then gives everything to "Andy"

I do not have any clue if it is possible So it alone knows to do it. I really hope you guys can help me.

You can use String.split () See string is different in different strings at any time of a string in the string. String [] parts = code.split ("start:"); // Creates parts before starting: and after the start: parts = parts [1] .split ("ende"); // Before the end and the string results = parts [parts] after for parts; // Here is a result

problem with multiple ende :

If more than one ende In the code it will not work in this way, so you have to choose a different solution where you can add other parts back:

  string [] parts = code.split ("Start: "); Parts = parts [1] .split ("ende"); String result = parts [0]; // Special case: // Add each split sub string, but the last int ii (ii = 1; i & lt; parts.length-1; i ++) {Results + = Part [i]; }    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -