Cree el siguiente codigo
Código java:
Ver original/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author Administrador
*/
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main
(String[] args
) URL url
= new URL("http://www.megaupload.com/?d=44DIF7IK"); int i=1;
linea = in.readLine();
while ((linea = in.readLine()) != null && i < 174) {
i++;
}
Pattern p = Pattern.compile("<a href=\"([^#])\"");
Matcher m = p.matcher(linea);
System.
out.
println(m.
group(1)); }
}
La variable linea queda con esto:
<a href="http://www1302.megaupload.com/files/95ac04563ae9e5e8d17c317fd1cd2291/Hous803.mp4" class="download_regular_usual" onclick="javascript
:window.open('http://s.megaclick.com/ad.code?de=cc56cc9f-402821bf-b4593bef-319dfc3c-23f5b-3-1b943&tm=1323634368.87706&du=aHR0cDovL2FmZi5yaW5nd G9uZXBhcnRuZXIuY29tL2dlby9wcmVzZXQvMzcwMy8xLzEzNjA vMC8%3d%0a','popunder','width=800,height=800,scrol lbars=yes,status=no,resizable=yes, toolbar=no'); window.focus();" style="display:none;" id="dlbutton"></a>
Yo necesito sacar esto:
http://www1302.megaupload.com/files/...91/Hous803.mp4
Pero tengo un problema en
Pattern p = Pattern.compile("<a href=\"([^#])\"");
Matcher m = p.matcher(linea);
System.out.println(m.group(1));
Me da el siguiente error:
run:
Exception in thread "main" java.lang.IllegalStateException: No match found
at java.util.regex.Matcher.group(Matcher.java:468)
at javaapplication1.JavaApplication1.main(JavaApplica tion1.java:38)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
¿Alguien sabe como puedo solucionarlo?
PD: Es la primera vez que uso java