Home > Back-end >  How to solve the Java file stream string slash automatically convert into the backslash problems
How to solve the Java file stream string slash automatically convert into the backslash problems

Time:12-17

File stream he will slash into a backslash, Linux only know slash, and then can't read the file, I used the file. The separator also not line, because after a on the flow, it will put forward slash to the backslash, can have what way to solve?
My case similar to this post,
https://bbs.csdn.net/topics/390885581

CodePudding user response:

 
HttpClient=HttpClients. CreateDefault ();
HttpPost HttpPost=new HttpPost (url);

InputStream InputStream=new FileInputStream (filePath);

MultipartEntityBuilder builder=MultipartEntityBuilder. The create ();

Builder. SetCharset (Charset. Class.forname (" utf-8 "));
Builder. SetMode (HttpMultipartMode. BROWSER_COMPATIBLE);

Builder. AddBinaryBody (name, inputStream, ContentType. Create (" multipart/form - data ", Consts UTF_8), fileName);


This is the code I wrote, in the Windows environment, read the absolute path will be a problem, but the absolute path under Linux, will become the backslash backslash, thus path to find and get file
  • Related