title: send file as a data binary to http post spring boot
body: <p>I have a curl command:</p>
  <pre><code>curl -X POST &quot;https:example.com/upload&quot; -H &quot;accept: application/json&quot; -H &quot;Authorization: token&quot; -H
  &quot;Content-Type: text/plain&quot; --data-binary @&quot;filename.txt&quot;
  </code></pre>
  <p>this is the code so far:</p>
  <pre><code>SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
              URL url = new URL(&quot;https://example.com/upload&quot;);
              HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
              conn.setDoOutput(true);
              conn.setSSLSocketFactory(sslsocketfactory);
              conn.setRequestMethod(&quot;POST&quot;);
              conn.setRequestProperty(&quot;accept&quot;, &quot;application/json&quot;);
              conn.setRequestProperty(&quot;Authorization&quot;, encodedValue);
              conn.setRequestProperty(&quot;Content-Type&quot;, &quot;text/plain&quot;);
              OutputStream os = new BufferedOutputStream(conn.getOutputStream());
              byte[] bytes = Files.readAllBytes(Paths.get(filePath));
               
              os.write(bytes);
              os.flush();
              
              int respCode = conn.getResponseCode();
              System.out.println(respCode);
  
              if (conn.getResponseCode() != 404) {
                  InputStream inputstream = conn.getInputStream();
                  InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
                  BufferedReader bufferedreader = new BufferedReader(inputstreamreader);
  while ((client = bufferedreader.readLine()) != null) {
                      response.getWriter().println(client);
                  }
              }
  </code></pre>
  <p>I am getting a 404 response.</p>
  <p>can someone help me what am I doing wrong here? Please and thanks.</p>