أردت هنا الحصول على الcontent لأي صفحه أدخلها بالـ URL بعد ذلك واجهتني مشكلة الـ Matcher لا أعلم أين الخطأ
حاولت أضيف أكثر من import لكن بدون فائده حاولت إضافة كلاس لكن بدون جدوى..حاولت ولكن كان لابد من السؤال
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.regex.Matcher;
/**
*
* @author xp
*/
public class Main {
/**
* @param args the command line arguments
*/
// TODO code application logic here
URL url = new URL("http://www.google.com");
Matcher match = pattern.matcher(getContent(url));
public static CharSequence getContent(URL url) throws IOException {
URLConnection conn = url.openConnection();
String encoding = conn.getContentEncoding();
if (encoding == null) {
encoding = "ISO-8859-1";
}
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), encoding));
StringBuilder sb = new StringBuilder(16384);
try {
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
sb.append('\n');
}
}
catch(Exception e) {
e.printStackTrace();
}
finally {
br.close();
}
return sb;
}
}
package url;
إعذروني يااخوان اذا كان تنسيق الموضوع سئ فاأنا قليل الدخول للمنتديات ..ودمتم بكل حب أحبتي