この文字列を Web サイトから解析して識別し、色を変数に格納します (緑が値 0 を割り当てるか、それ以外の場合は 1 とします)。
<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) 正しいですか?つまり、コメントを、私が望むことを行うコードに置き換える必要がありますよね? 2)私はJavaが初めてなのでコードとテキストで「遊ぶ」方法を手伝ってもらえますか?