0

プログラミング初心者です。
pythonを使ってメッセージと画像を送信する方法はよく出てくるのですが、これをjavaでやろうと思うとどう書けば良いのかわからないです。
目ぼしい情報は調べたのですが具体的にどう書けば良いのかわかりません。
以下のコードはメッセージを送信するためのメソッドです。
ここからどういう感じで変えていけば良いのか教えていただけたら幸いです。

public void notify(String message) {
    HttpURLConnection connection = null;
    try {
        URL url = new URL("https://notify-api.line.me/api/notify");
        connection = (HttpURLConnection) url.openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        connection.addRequestProperty("Authorization", "Bearer " + token);
        try (OutputStream os = connection.getOutputStream();
                PrintWriter writer = new PrintWriter(os)) {
            writer.append("message=").append(URLEncoder.encode(message, "UTF-8")).flush();
            try (InputStream is = connection.getInputStream();
                    BufferedReader r = new BufferedReader(new InputStreamReader(is))) {
                String res = r.lines().collect(Collectors.joining());
                if (!res.contains("\"message\":\"ok\"")) {
                    System.out.println(res);
                }
            }
        }
    } catch (Exception ignore) {
    } finally {
        if (connection != null) {
            connection.disconnect();
        }
    }
}

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。