【檔案操作】Http的request上傳檔案獲取檔名稱
阿新 • • 發佈:2019-01-04
public static String getFileName(InputStream is) throws IOException { StringBuffer sb = new StringBuffer(); int count = 0; while (true) { int a = is.read(); sb.append((char) a); if (a == '\r') { count++; } if (count == 4) { is.read(); break; } } String title = sb.toString(); System.out.println(title); String[] titles = title.split("\r\n"); String fileName = titles[1].split(";")[2].split("=")[1].replace("\"", ""); return fileName; }