System.out.println("Please enter the website :");
Scanner scan2 = new Scanner(System.in);
String word2 = scan2.nextLine();
try {
URL my_url = new URL("http://" + word2 + "/");
BufferedReader br = new BufferedReader(new InputStreamReader(
my_url.openStream()));
String strTemp = "";
while (null != (strTemp = br.readLine())) {
_resultArea.append(strTemp + newline);
}
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("\n");
System.out.println("\n");
System.out.println("\n");
String url = "http://" + word2 + "/";
print("Fetching %s...", url);
try{
Document doc = Jsoup.connect(url).get();
Elements links = doc.select("a[href]");
System.out.println("\n");
BufferedWriter bw = new BufferedWriter(new FileWriter("C:\\Users\\user\\fypworkspace\\FYP\\Link\\abc.txt"));
_resultArea.append("\n");
for (Element link : links) {
print(" %s ", link.attr("abs:href"), trim(link.text(), 35));
bw.write(link.attr("abs:href"));
bw.write(System.getProperty("line.separator"));
}
bw.flush();
bw.close();
} catch (IOException e1) {
Hi, this is my code to extract links from a web address. The user will key in the desired URL and this code will extract links from the URL.
This code prompt the user to key in for URL in the ECLIPSE IDE console. After keyed in the input, the code will extract links from the URL and transfer the output to a JTextArea.
What i wanted to do now is, i would like to create a Jtextfield to receive the user input rather than the user key in the input inside the console.
The line of code that is responsible for handling the string input is :
URL my_url = new URL("http://" + word2 + "/");
and
String url = "http://" + word2 + "/";
I have not much experience in development of GUI, i hope someone can guide me. Thanks.