私はこの文字列をウェブサイトとidentifから解析し、変数に色を格納したいと考えています(緑色の値が0か、それ以外の場合は1)。私はこのデモのコードを発見したparsin text from .htmlページjava
<tr><td class="mapbuttons" align=right>
<a href="http://www...."><font color=green>TEXT <font color=#ff8000>(2)</font>3/14</font></a>
:
import java.net.*;
import java.io.*;
public class WebSiteReader {
public static void main(String args[]){
String nextLine;
URL url = null;
URLConnection urlConn = null;
InputStreamReader inStream = null;
BufferedReader buff = null;
try{
// Create the URL obect that points
// at the default file index.html
url = new URL("http://www.yahoo.com");
urlConn = url.openConnection();
inStream = new InputStreamReader(
urlConn.getInputStream());
buff= new BufferedReader(inStream);
// get the values I want here
} catch(MalformedURLException e){
System.out.println("Please check the URL:" +
e.toString());
} catch(IOException e1){
System.out.println("Can't read from the Internet: "+
e1.toString());
}
}
}
1)は、それがcorrenctですか?私は私の希望をしているcodewhichとのコメントを置き換えるために私はちょうどいいですか? 2)私はJavaの初心者で、テキストを使って "遊ぶ"というコードを手伝ってもらえますか?
再生したい場合は、文字列とパターンのクラスを使用しています。これらの正規表現は大きくて醜いものになるでしょうが、それらは機能します - それはちょうど遊びの解決策です:) – wuppi