1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

javaでズンドコゲッター

Last updated at Posted at 2016-05-29

概要

javaでズンドコゲッターやってみた。

実際

サンプルコード

import java.io.*;
import java.net.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int zunCount = 0;
        while (true) 
        {
            String word = zundoko();
            System.out.print(word);
            System.out.print(" ");
            if (word.equals("ズン")) 
            {
                zunCount++;
            }
            else if (zunCount == 4)
            {
                System.out.print("キ・ヨ・シ!");
                break;
            } 
            else
            {
                zunCount = 0;
            }
        }
    }
    private static String zundoko() throws Exception {
        URL url = new URL("http://ohijs0.paas.jp-e1.cloudn-service.com/zundoko");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        InputStream stream = connection.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "utf8"));
        StringBuilder builder = new StringBuilder();
        String line = "";
        while ((line = reader.readLine()) != null) 
        {
            builder.append(line);
        }
        return builder.toString();   
    }        
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?