如何将文件输入流字节作为八位字节流?
how to get fileinputstream bytes as octetstream?
朋友们好,我正在尝试发送 post 请求。在 wireshark 正文中似乎是这样
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="csrf_token"
csrf:MxLfAIgtghMohbOWeEwFv11Ou8eedDFQO0NXw6DGcZC1w1hTDo1umrysYcxho6bX
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="imagefilename"; filename="myFilemain.bin"
Content-Type: application/octet-stream
...qz...OO.M..g...`.:...../o.up.........G............y......f;....&Il..*..A.........0. E.fP.P------------------here is my bin file bytes---------------
..C.x...Q..J.._+%.. bla bla
但是当我在代码端 post 时,它看起来像这样:
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="csrf_token"
csrf:MxLfAIgtghMohbOWeEwFv11Ou8eedDFQO0NXw6DGcZC1w1hTDo1umrysYcxho6bX
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="imagefilename"; filename="myFilemain.bin"
Content-Type: application/octet-stream
²qz‹ÁOOõMÓâg‘Ç`:Êëá‡/oåupˆéìŒÛ.Ó‰G²¹²ƒö‘•®yñúÇÌ°f;ª¥ŸÉ&Il³š*ÄAŞøØÄñŠ…¦0Ğ EfP½P
£¢CÓxÀQÃJ¥_+%ã—¢ÌGà¸,Öû¶a4ªW&Ú×zÇñg~5. ³%FÀìDëÀ²tñş)Aéåf>¥jÀƒã8 ±šeH™Íäi“ktÇ ‡0¢û³ımİp‘}à
------WebKitFormBoundaryPGENMvyXR2Vt226r--
如何将字节作为八位字节流
这是我的代码:
FileInputStream fis = null;
try {
fis = new FileInputStream(uploadFile);
InputStreamReader inputStreamReader = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(inputStreamReader);
String line;
while ((line = br.readLine()) != null) {
builder.append(line.toCharArray());//stringBuilder
System.out.println(line.toCharArray());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
here 是关于 multiPart 文件上传示例的一些信息。
朋友们好,我正在尝试发送 post 请求。在 wireshark 正文中似乎是这样
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="csrf_token"
csrf:MxLfAIgtghMohbOWeEwFv11Ou8eedDFQO0NXw6DGcZC1w1hTDo1umrysYcxho6bX
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="imagefilename"; filename="myFilemain.bin"
Content-Type: application/octet-stream
...qz...OO.M..g...`.:...../o.up.........G............y......f;....&Il..*..A.........0. E.fP.P------------------here is my bin file bytes---------------
..C.x...Q..J.._+%.. bla bla
但是当我在代码端 post 时,它看起来像这样:
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="csrf_token"
csrf:MxLfAIgtghMohbOWeEwFv11Ou8eedDFQO0NXw6DGcZC1w1hTDo1umrysYcxho6bX
------WebKitFormBoundaryPGENMvyXR2Vt226r
Content-Disposition: form-data; name="imagefilename"; filename="myFilemain.bin"
Content-Type: application/octet-stream
²qz‹ÁOOõMÓâg‘Ç`:Êëá‡/oåupˆéìŒÛ.Ó‰G²¹²ƒö‘•®yñúÇÌ°f;ª¥ŸÉ&Il³š*ÄAŞøØÄñŠ…¦0Ğ EfP½P
£¢CÓxÀQÃJ¥_+%ã—¢ÌGà¸,Öû¶a4ªW&Ú×zÇñg~5. ³%FÀìDëÀ²tñş)Aéåf>¥jÀƒã8 ±šeH™Íäi“ktÇ ‡0¢û³ımİp‘}à
------WebKitFormBoundaryPGENMvyXR2Vt226r--
如何将字节作为八位字节流
这是我的代码:
FileInputStream fis = null;
try {
fis = new FileInputStream(uploadFile);
InputStreamReader inputStreamReader = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(inputStreamReader);
String line;
while ((line = br.readLine()) != null) {
builder.append(line.toCharArray());//stringBuilder
System.out.println(line.toCharArray());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
here 是关于 multiPart 文件上传示例的一些信息。