Created
October 23, 2010 10:19
-
-
Save tejima/642031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.net.*; | |
import java.util.regex.*; | |
public class Main4 { | |
public static void main(String args[]) { | |
int n = 0; | |
Pattern p = Pattern.compile("--> (\\d+)</font>"); | |
try { | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
while(true) { | |
String line1 = br.readLine(); | |
if(line1 == null){break;} | |
URL url = new URL("http://www.tulips.tsukuba.ac.jp/scripts/roman_numerals?romasuji=" + line1); | |
Object content = url.getContent(); | |
if( content instanceof InputStream ) { | |
BufferedReader reader | |
= new BufferedReader( | |
new InputStreamReader( (InputStream)content ) ); | |
String line; | |
while( ( line = reader.readLine() ) != null ) { | |
Matcher m1 = p.matcher(line); | |
if(m1.find()){ | |
System.out.println(m1.group(1)); | |
} | |
} | |
reader.close(); | |
} else { | |
System.out.println( "This content is " + content.toString() ); | |
} | |
//System.out.println(result); | |
} | |
br.close(); | |
} | |
catch (IOException err){ | |
//System.out.println(err); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment