Here you can find the source of getFileName(HttpURLConnection conn)
private static String getFileName(HttpURLConnection conn)
//package com.java2s; //License from project: Apache License import java.net.HttpURLConnection; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final Pattern REGEX_FILE_NAME = Pattern.compile("attachment;filename=\"([\\w\\-]+)\""); private static String getFileName(HttpURLConnection conn) { String fileName = conn.getHeaderField("Content-Disposition"); Matcher matcher = REGEX_FILE_NAME.matcher(fileName); if (matcher.find()) { return matcher.group(1); }//from w w w . j a va2 s.co m return null; } }