「Java ContentDisposition からファイル名を抜き出す」の版間の差分
ナビゲーションに移動
検索に移動
| 1行目: | 1行目: | ||
==Java ContentDisposition からファイル名を抜き出す== | ==Java ContentDisposition からファイル名を抜き出す== | ||
| − | [[Java]]{{category 正規表現}} | + | [[Java]] | {{category 正規表現}} |
Pattern ptn = Pattern.compile(".*filename\\s*=\\s*[\"]{0,1}([^\"]+)[\"]{0,1}.*") | Pattern ptn = Pattern.compile(".*filename\\s*=\\s*[\"]{0,1}([^\"]+)[\"]{0,1}.*") | ||
Matcher matcher = ptn.matcher(contentDisposition); | Matcher matcher = ptn.matcher(contentDisposition); | ||
2020年2月15日 (土) 08:36時点における版
Java ContentDisposition からファイル名を抜き出す
Pattern ptn = Pattern.compile(".*filename\\s*=\\s*[\"]{0,1}([^\"]+)[\"]{0,1}.*")
Matcher matcher = ptn.matcher(contentDisposition);
if (matcher.matches()) {
filename = matcher.group(1);
}
© 2006 矢木浩人