「大人しくしてろよ、すぐ終わるからよ!」
でお馴染みの
s
m
d
です。(s^m^)d
さて、
僕は、
バイクを所持しています。
FTR223

屋根つきの駐車場に停めているので、最近はシートをかけない事が多い。
したらば
バイク買取のチラシがバイクに挟まれていました。
よくある光景ですが、、、
少し違うのが
勝手に査定されていること。
5万円って・・・
何様だ(#゚Д゚)ゴルァ!!
10万円積まれたって売らねえよ!!!…多分。

ホント、朝から気分が悪いぜ。
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
/**
* 指定したURLのファイルをダウンロードするクラス
*
* @author smdbanana
*/
public class DownloadFromUrl {
/**
* お約束のメインメソッド
*
* @param args
*/
public static void main(String[] args) {
try {
// args[0] = ダウンロード先のURL
// args[1] = 保存するパス
download(args[0], args[1]);
}
catch (MalformedURLException e) {
e.printStackTrace(); // 独自の例外処理を書くんだ(;´Д`)
}
catch (FileNotFoundException e) {
e.printStackTrace(); // 独自の例外処理を書くんだ(;´Д`)
}
catch (IOException e) {
e.printStackTrace(); // 独自の例外処理を書くんだ(;´Д`)
}
catch (Exception e) {
e.printStackTrace(); // 独自の例外処理を書くんだ(;´Д`)
}
}
/**
* ダウンロードのコアメソッド
*
* @param strUrl ダウンロード先のURL
* @param outputPath 保存するパス
* @throws MalformedURLException
* @throws FileNotFoundException
* @throws IOException
*/
public static void download(String strUrl, String outputPath) throws MalformedURLException, FileNotFoundException,
IOException {
URL url = new URL(strUrl);
FileOutputStream fos = new FileOutputStream(outputPath);
InputStream is = url.openStream();
while (true) {
int read = is.read();
if (read == -1)
break;
fos.write(read);
}
fos.close();
}
}