Package java.io

Examples of java.io.DataOutputStream.writeBytes()


      setupDoInputOutputFlag();
      Map<String, Object> params = request.getParams();
      if (null != params && params.size() > 0) {
        DataOutputStream outs = new DataOutputStream(conn.getOutputStream());
        for (Entry<String,?> entry : params.entrySet()) {
          outs.writeBytes("--" + boundary + SEPARATOR);
          String key = entry.getKey();
          File f = null;
          if (entry.getValue() instanceof File)
            f = (File)entry.getValue();
          else if (entry.getValue() instanceof String)
View Full Code Here


          if (entry.getValue() instanceof File)
            f = (File)entry.getValue();
          else if (entry.getValue() instanceof String)
            f = Files.findFile(entry.getValue().toString());
          if (f != null && f.exists()) {
            outs.writeBytes("Content-Disposition:  form-data;  name=\""
                    + key
                    + "\";  filename=\""
                    + entry.getValue()
                    + "\"\r\n");
            outs.writeBytes("Content-Type:   application/octet-stream\r\n\r\n");
View Full Code Here

            outs.writeBytes("Content-Disposition:  form-data;  name=\""
                    + key
                    + "\";  filename=\""
                    + entry.getValue()
                    + "\"\r\n");
            outs.writeBytes("Content-Type:   application/octet-stream\r\n\r\n");
            if(f.length() == 0)
              continue;
            InputStream is = Streams.fileIn(f);
            byte[] buffer = new byte[is.available()];
            while (true) {
View Full Code Here

              int amountRead = is.read(buffer);
              if (amountRead == -1) {
                break;
              }
              outs.write(buffer, 0, amountRead);
              outs.writeBytes("\r\n");
            }
            Streams.safeClose(is);
          } else {
            outs.writeBytes("Content-Disposition:  form-data;  name=\""
                    + key
View Full Code Here

              outs.write(buffer, 0, amountRead);
              outs.writeBytes("\r\n");
            }
            Streams.safeClose(is);
          } else {
            outs.writeBytes("Content-Disposition:  form-data;  name=\""
                    + key
                    + "\"\r\n\r\n");
            outs.writeBytes(entry.getValue() + "\r\n");
          }
        }
View Full Code Here

            Streams.safeClose(is);
          } else {
            outs.writeBytes("Content-Disposition:  form-data;  name=\""
                    + key
                    + "\"\r\n\r\n");
            outs.writeBytes(entry.getValue() + "\r\n");
          }
        }
        outs.writeBytes("--" + boundary + "--" + SEPARATOR);
        Streams.safeFlush(outs);
        Streams.safeClose(outs);
View Full Code Here

                    + key
                    + "\"\r\n\r\n");
            outs.writeBytes(entry.getValue() + "\r\n");
          }
        }
        outs.writeBytes("--" + boundary + "--" + SEPARATOR);
        Streams.safeFlush(outs);
        Streams.safeClose(outs);
      }

      return createResponse(getResponseHeader());
View Full Code Here

     */
    private void writeErrorToClient(String message) {
        try {
            OutputStream sockOut = clientSocket.getOutputStream();
            DataOutputStream out = new DataOutputStream(sockOut);
            out.writeBytes(message);
            out.flush();
        } catch (Exception e) {
            log.warn("Exception while writing error", e);
        }
    }
View Full Code Here

      conn.setAllowUserInteraction(false);
      conn.setUseCaches(false);
    conn.setDoOutput(true);
   
    DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
      wr.writeBytes(request);
      wr.close();
        return conn;
  }
 
  public static String getConnectionContent(HttpURLConnection conn) throws IOException {
View Full Code Here

    public static byte[] stringToBytes(final String s) throws IOException {
        final ByteArrayOutputStream byteOS = new ByteArrayOutputStream();
        final DataOutputStream dataStream = new DataOutputStream(byteOS);

        try {
            dataStream.writeBytes(s);
            dataStream.flush();
            return byteOS.toByteArray();
        } finally {
            dataStream.close();
            byteOS.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.