javatips.net counter

Java Examples for java.io.OutputStream

The following java examples will help you to understand the usage of java.io.OutputStream. These source code samples are taken from different open source projects.

Example 1
Project: stomptomanagerbridge-master  File: Transmitter.java View source code
public static void transmit(Command c, Map h, String b, java.io.OutputStream out) throws IOException {
    StringBuffer message = new StringBuffer(c.toString());
    message.append("\n");
    if (h != null) {
        for (Iterator keys = h.keySet().iterator(); keys.hasNext(); ) {
            String key = (String) keys.next();
            String value = (String) h.get(key);
            message.append(key);
            message.append(":");
            message.append(value);
            message.append("\n");
        }
    }
    message.append("\n");
    if (b != null)
        message.append(b);
    message.append("\000");
    out.write(message.toString().getBytes(Command.ENCODING));
}
Example 2
Project: acfun-new-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 3
Project: actionbar-sherlock-viewpager-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 4
Project: android-playlistr-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 5
Project: AndroidStore-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 6
Project: Android_App_OpenSource-master  File: StreamUtils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 7
Project: appengine-endpoints-booking-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 8
Project: ARKOST-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 9
Project: deepnighttwo-master  File: CleanDisk.java View source code
/**
     * @param args
     * @throws IOException
     */
public static void main(String[] args) throws IOException {
    byte[] e = new byte[1024 * 1024];
    OutputStream os = new FileOutputStream("/home/mengzang/eeeeeeeeeee");
    int size = 1024 * 110;
    for (int i = 0; i < size; i++) {
        os.write(e);
        if (i % 1024 == 0) {
            System.out.println((i / 1024) + "G");
        }
    }
    System.out.println("Finished.");
}
Example 10
Project: fanfoudroid-master  File: StreamUtils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 11
Project: Frescodemo-master  File: FileUtils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 12
Project: hexa.tools-master  File: StreamTools.java View source code
public static boolean copyStream(InputStream input, OutputStream output) {
    try {
        int size = 4096;
        byte[] buffer = new byte[size];
        int read = 0;
        do {
            read = input.read(buffer);
            if (read > 0)
                output.write(buffer, 0, read);
        } while (read == size);
        return true;
    } catch (IOException e) {
        return false;
    }
}
Example 13
Project: i-board-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 14
Project: intellij-community-master  File: ExceptionFromFinallyNesting.java View source code
private void run(int port) throws Exception {
    Socket socket = new Socket("localhost", port);
    try {
        InputStream inputReader = socket.getInputStream();
        try {
            OutputStream outputWriter = socket.getOutputStream();
            try {
                while (true) {
                    inputReader.read();
                }
            } finally {
                outputWriter.close();
            }
        } finally {
            inputReader.close();
        }
    } finally {
        socket.close();
    }
}
Example 15
Project: Joomla-Day-Brasil-2011-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 16
Project: kaorisan-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 17
Project: KarungGuniApp-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 18
Project: LazyList-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 19
Project: mobile-client-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 20
Project: MusicDNA-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 21
Project: ONE_PIECE_OV-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 22
Project: Open-Vehicle-Android-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 23
Project: OrderNowAndroid-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 24
Project: pps_android-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 25
Project: PullToRefreshStaggeredGridViewDemo-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 26
Project: RCS-android-demo-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 27
Project: SecurePhoto-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 28
Project: senses-lbs-social-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 29
Project: StaggeredGridViewDemo-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 30
Project: StudyGroupX-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 31
Project: t-board-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 32
Project: TheRoll-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 33
Project: trending-round-android-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 34
Project: v2droid-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 35
Project: YikuairAndroid-master  File: Utils.java View source code
public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
        byte[] bytes = new byte[buffer_size];
        for (; ; ) {
            int count = is.read(bytes, 0, buffer_size);
            if (count == -1)
                break;
            os.write(bytes, 0, count);
        }
    } catch (Exception ex) {
    }
}
Example 36
Project: intellij-haxe-master  File: OutputAdapter.java View source code
@Override
public java.lang.Object __hx_setField(java.lang.String field, java.lang.Object value, boolean handleProperties) {
    {
        boolean __temp_executeDef63 = true;
        switch(field.hashCode()) {
            case 107313:
                {
                    if (field.equals("mOs")) {
                        __temp_executeDef63 = false;
                        this.mOs = ((java.io.OutputStream) (value));
                        return value;
                    }
                    break;
                }
        }
        if (__temp_executeDef63) {
            return super.__hx_setField(field, value, handleProperties);
        } else {
            throw null;
        }
    }
}
Example 37
Project: josm-plugins-master  File: CoderMixer2ST.java View source code
public int GetOutStream(RecordVector<java.io.OutputStream> outStreams, //  const UInt64 **outSizes,
Object useless_outSizes, int streamIndex, java.io.OutputStream[] outStreamRes) {
    java.io.OutputStream seqOutStream;
    int i;
    for (i = 0; i < _bindInfo.OutStreams.size(); i++) if (_bindInfo.OutStreams.get(i) == streamIndex) {
        seqOutStream = outStreams.get(i);
        // seqOutStream.Detach();
        outStreamRes[0] = seqOutStream;
        return HRESULT.S_OK;
    }
    int binderIndex = _bindInfo.FindBinderForOutStream(streamIndex);
    if (binderIndex < 0)
        return HRESULT.E_INVALIDARG;
    int tmp1[] = new int[1];
    int tmp2[] = new int[1];
    _bindInfo.FindInStream(_bindInfo.BindPairs.get(binderIndex).InIndex, tmp1, /* coderIndex*/
    tmp2);
    int coderIndex = tmp1[0];
    CoderInfo coder = _coders.get(coderIndex);
    if (coder.Coder == null)
        return HRESULT.E_NOTIMPL;
    try {
        // coder.Coder.QueryInterface(IID_ISequentialOutStream, &seqOutStream);
        seqOutStream = (java.io.OutputStream) coder.Coder;
    } catch (java.lang.ClassCastException e) {
        return HRESULT.E_NOTIMPL;
    }
    int startIndex = _bindInfo.GetCoderOutStreamIndex(coderIndex);
    if (coder.Coder == null)
        return HRESULT.E_NOTIMPL;
    ICompressSetOutStream setOutStream = null;
    try {
        // coder.Coder.QueryInterface(IID_ICompressSetOutStream, &setOutStream);
        setOutStream = (ICompressSetOutStream) coder.Coder;
    } catch (java.lang.ClassCastException e) {
        return HRESULT.E_NOTIMPL;
    }
    if (coder.NumOutStreams > 1)
        return HRESULT.E_NOTIMPL;
    for (i = 0; i < coder.NumOutStreams; i++) {
        java.io.OutputStream[] tmp = new java.io.OutputStream[1];
        int res = GetOutStream(outStreams, useless_outSizes, startIndex + i, tmp);
        if (res != HRESULT.S_OK)
            return res;
        java.io.OutputStream seqOutStream2 = tmp[0];
        res = setOutStream.SetOutStream(seqOutStream2);
        if (res != HRESULT.S_OK)
            return res;
    }
    // seqOutStream.Detach();
    outStreamRes[0] = seqOutStream;
    return HRESULT.S_OK;
}
Example 38
Project: yajsw-master  File: TeeOutputStream.java View source code
/**
	 * Disconnect.
	 * 
	 * @param sink
	 *            the sink
	 */
public synchronized void disconnect(OutputStream sink) {
    if (sinks.length == 0)
        return;
    OutputStream[] newSinks = new OutputStream[sinks.length - 1];
    int j = 0;
    boolean removed = false;
    for (int i = 0; i < sinks.length && j < newSinks.length; i++) {
        if (sink != sinks[i]) {
            newSinks[j] = sinks[i];
            j++;
        } else
            removed = true;
    }
    if (removed)
        sinks = newSinks;
}
Example 39
Project: yajsw-maven-master  File: TeeOutputStream.java View source code
/**
	 * Disconnect.
	 * 
	 * @param sink
	 *            the sink
	 */
public synchronized void disconnect(OutputStream sink) {
    if (sinks.length == 0)
        return;
    OutputStream[] newSinks = new OutputStream[sinks.length - 1];
    int j = 0;
    boolean removed = false;
    for (int i = 0; i < sinks.length && j < newSinks.length; i++) {
        if (sink != sinks[i]) {
            newSinks[j] = sinks[i];
            j++;
        } else
            removed = true;
    }
    if (removed)
        sinks = newSinks;
}
Example 40
Project: yajsw-maven-mk2-master  File: TeeOutputStream.java View source code
/**
	 * Disconnect.
	 * 
	 * @param sink
	 *            the sink
	 */
public synchronized void disconnect(OutputStream sink) {
    if (sinks.length == 0)
        return;
    OutputStream[] newSinks = new OutputStream[sinks.length - 1];
    int j = 0;
    boolean removed = false;
    for (int i = 0; i < sinks.length && j < newSinks.length; i++) {
        if (sink != sinks[i]) {
            newSinks[j] = sinks[i];
            j++;
        } else
            removed = true;
    }
    if (removed)
        sinks = newSinks;
}
Example 41
Project: vnet-sms-master  File: EmbeddedClamshellLauncher.java View source code
/**
	 * @see vnet.sms.common.shell.clamshellspring.ClamshellLauncher#launch(java.io.InputStream,
	 *      java.io.OutputStream)
	 */
@Override
public void launch(final InputStream input, final OutputStream output) {
    this.log.info("Launching a new clamshell using input = {} and output = {} ...", input, output);
    this.context.putValue(Context.KEY_INPUT_STREAM, input);
    this.context.putValue(Context.KEY_OUTPUT_STREAM, output);
    this.context.getShell().plug(this.context);
    this.log.info("Clamshell has been terminated");
}
Example 42
Project: airship-master  File: ZipPackager.java View source code
public static void packageEntries(OutputStream output, Map<String, ByteSource> entries) throws IOException {
    ZipOutputStream out = new ZipOutputStream(output);
    for (Map.Entry<String, ByteSource> entry : entries.entrySet()) {
        String path = entry.getKey();
        ZipEntry fileEntry = new ZipEntry(path);
        out.putNextEntry(fileEntry);
        entry.getValue().copyTo(out);
    }
    out.finish();
}
Example 43
Project: Aspose_Pdf_Java-master  File: ExportBookmarksToXMLFromAnExistingPDFFile.java View source code
public static void exportBookmarksToXML() throws IOException {
    // Create PdfBookmarkEditor object
    PdfBookmarkEditor bookmarkeditor = new PdfBookmarkEditor();
    // Open PDF file
    bookmarkeditor.bindPdf("Input.pdf");
    OutputStream os = new FileOutputStream("bookmark.xml");
    bookmarkeditor.exportBookmarksToXML(os);
    bookmarkeditor.dispose();
}
Example 44
Project: bc-java-master  File: TlsRSAUtils.java View source code
/*
     * Generate a pre_master_secret and send it encrypted to the server
     */
public static TlsSecret generateEncryptedPreMasterSecret(TlsContext context, TlsCertificate certificate, OutputStream output) throws IOException {
    TlsSecret preMasterSecret = context.getCrypto().generateRSAPreMasterSecret(context.getClientVersion());
    byte[] encryptedPreMasterSecret = preMasterSecret.encrypt(certificate);
    if (TlsUtils.isSSL(context)) {
        // TODO Do any SSLv3 servers actually expect the length?
        output.write(encryptedPreMasterSecret);
    } else {
        TlsUtils.writeOpaque16(encryptedPreMasterSecret, output);
    }
    return preMasterSecret;
}
Example 45
Project: BitLib-master  File: FileUtil.java View source code
public static void copy(InputStream in, File file) {
    try {
        OutputStream out = new FileOutputStream(file);
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        out.close();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 46
Project: Cosmetics-master  File: FileUtils.java View source code
/**
     * Copies a file.
     *
     * @param in   The file to copy.
     * @param file Destination.
     */
public static void copy(InputStream in, File file) {
    try {
        OutputStream out = new FileOutputStream(file);
        byte[] buf = new byte[1024];
        int len;
        while ((len = in.read(buf)) > 0) out.write(buf, 0, len);
        out.close();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 47
Project: e2stream-installer-master  File: ErrorResponse.java View source code
public void handle(HttpExchange t) throws IOException {
    java.nio.file.Path p = Paths.get("error.html", new String[0]);
    Headers responseHeaders = t.getResponseHeaders();
    responseHeaders.set("Content-Type", "text/html");
    t.sendResponseHeaders(200, response.length());
    OutputStream os = t.getResponseBody();
    os.write(response.getBytes());
    os.close();
}
Example 48
Project: http-kit-master  File: PiplelineTest.java View source code
public static void main(String[] args) throws UnknownHostException, IOException {
    Socket socket = new Socket("127.0.0.1", 9091);
    InputStream is = socket.getInputStream();
    OutputStream os = socket.getOutputStream();
    String req = "GET / HTTP/1.0\r\n\r\n";
    os.write((req + req + req).getBytes());
    os.flush();
    byte buffer[] = new byte[8096000];
    int read = is.read(buffer);
    System.out.println(new String(buffer, 0, read));
}
Example 49
Project: irma_future_id-master  File: MessageImprintBuilder.java View source code
public MessageImprint build(byte[] message) throws DVCSException {
    try {
        OutputStream dOut = digestCalculator.getOutputStream();
        dOut.write(message);
        dOut.close();
        return new MessageImprint(new DigestInfo(digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));
    } catch (Exception e) {
        throw new DVCSException("unable to build MessageImprint: " + e.getMessage(), e);
    }
}
Example 50
Project: Java-ECOM-Project-master  File: Util.java View source code
public static ShellBuilder createShellBuilderWithInput(String input, OutputStream output, OutputStream error) throws UnsupportedEncodingException {
    input = input + "\n";
    ByteArrayInputStream inputStream = new ByteArrayInputStream(input.getBytes("UTF-8"));
    BaseContext c = new BaseContext();
    ShellBuilder sb = new ShellBuilder();
    sb.createNewShell(c, inputStream, new PrintStream(output), new PrintStream(error));
    return sb;
}
Example 51
Project: JavaInterview-master  File: TCPClient.java View source code
public static void main(String[] args) throws Exception {
    Socket socket = new Socket("localhost", 5678);
    InputStream is = socket.getInputStream();
    OutputStream os = socket.getOutputStream();
    String message = "This is client";
    os.write(message.getBytes());
    byte[] buffer = new byte[100];
    int length = is.read(buffer, 0, buffer.length);
    String response = new String(buffer, 0, length);
    System.out.println("The response: " + response);
}
Example 52
Project: jsmpp-master  File: SynchronizedPDUSender.java View source code
/*
     * (non-Javadoc)
     * 
     * @see org.jsmpp.PDUSender#sendSubmitSm(java.io.OutputStream, int,
     *      java.lang.String, org.jsmpp.TypeOfNumber,
     *      org.jsmpp.NumberingPlanIndicator, java.lang.String,
     *      org.jsmpp.TypeOfNumber, org.jsmpp.NumberingPlanIndicator,
     *      java.lang.String, org.jsmpp.bean.ESMClass, byte, byte,
     *      java.lang.String, java.lang.String,
     *      org.jsmpp.bean.RegisteredDelivery, byte, org.jsmpp.bean.DataCoding,
     *      byte, byte[], org.jsmpp.bean.OptionalParameter[])
     */
public byte[] sendSubmitSm(OutputStream os, int sequenceNumber, String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, String destinationAddr, ESMClass esmClass, byte protocolId, byte priorityFlag, String scheduleDeliveryTime, String validityPeriod, RegisteredDelivery registeredDelivery, byte replaceIfPresent, DataCoding dataCoding, byte smDefaultMsgId, byte[] shortMessage, OptionalParameter... optionalParameters) throws PDUStringException, IOException {
    synchronized (os) {
        return pduSender.sendSubmitSm(os, sequenceNumber, serviceType, sourceAddrTon, sourceAddrNpi, sourceAddr, destAddrTon, destAddrNpi, destinationAddr, esmClass, protocolId, priorityFlag, scheduleDeliveryTime, validityPeriod, registeredDelivery, replaceIfPresent, dataCoding, smDefaultMsgId, shortMessage, optionalParameters);
    }
}
Example 53
Project: Justaway-for-Android-Original-master  File: FileUtil.java View source code
public static File writeToTempFile(File cacheDir, InputStream inputStream) {
    if (!cacheDir.exists()) {
        if (!cacheDir.mkdirs()) {
            return null;
        }
    }
    File file = new File(cacheDir, "justaway-temp-" + System.currentTimeMillis() + ".jpg");
    try {
        OutputStream outputStream = new FileOutputStream(file);
        byte[] buffer = new byte[4096];
        int size;
        while (-1 != (size = inputStream.read(buffer))) {
            outputStream.write(buffer, 0, size);
        }
        inputStream.close();
        outputStream.close();
    } catch (Exception e) {
        return null;
    }
    return file;
}
Example 54
Project: KindleTERM-master  File: HttpOutboundStream.java View source code
public void flush() throws IOException {
    super.flush();
    HttpConnection outbound = (HttpConnection) Connector.open(url, Connector.READ_WRITE, false);
    outbound.setRequestMethod(HttpConnection.POST);
    OutputStream out = outbound.openOutputStream();
    out.write(toByteArray());
    out.close();
    outbound.openInputStream().close();
    reset();
}
Example 55
Project: midpssh-master  File: HttpOutboundStream.java View source code
public void flush() throws IOException {
    super.flush();
    HttpConnection outbound = (HttpConnection) Connector.open(url, Connector.READ_WRITE, false);
    outbound.setRequestMethod(HttpConnection.POST);
    OutputStream out = outbound.openOutputStream();
    out.write(toByteArray());
    out.close();
    outbound.openInputStream().close();
    reset();
}
Example 56
Project: monkeytest-master  File: LatestVersionResult.java View source code
public void execute(ActionInvocation invocation) throws Exception {
    LatestVersionSource source = (LatestVersionSource) invocation.getAction();
    double latestVersion = source.getLatestVersion();
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setContentType("text/xml");
    OutputStream out = response.getOutputStream();
    out.write(String.valueOf(latestVersion).getBytes());
    out.close();
}
Example 57
Project: muCommander-master  File: CoderMixer2ST.java View source code
public int GetOutStream(RecordVector<java.io.OutputStream> outStreams, //  const UInt64 **outSizes,
Object useless_outSizes, int streamIndex, java.io.OutputStream[] outStreamRes) {
    java.io.OutputStream seqOutStream;
    int i;
    for (i = 0; i < _bindInfo.OutStreams.size(); i++) if (_bindInfo.OutStreams.get(i) == streamIndex) {
        seqOutStream = outStreams.get(i);
        // seqOutStream.Detach();
        outStreamRes[0] = seqOutStream;
        return HRESULT.S_OK;
    }
    int binderIndex = _bindInfo.FindBinderForOutStream(streamIndex);
    if (binderIndex < 0)
        return HRESULT.E_INVALIDARG;
    int tmp1[] = new int[1];
    int tmp2[] = new int[1];
    _bindInfo.FindInStream(_bindInfo.BindPairs.get(binderIndex).InIndex, tmp1, /* coderIndex*/
    tmp2);
    int coderIndex = tmp1[0], coderStreamIndex = tmp2[0];
    CoderInfo coder = _coders.get(coderIndex);
    if (coder.Coder == null)
        return HRESULT.E_NOTIMPL;
    try {
        // coder.Coder.QueryInterface(IID_ISequentialOutStream, &seqOutStream);
        seqOutStream = (java.io.OutputStream) coder.Coder;
    } catch (java.lang.ClassCastException e) {
        return HRESULT.E_NOTIMPL;
    }
    int startIndex = _bindInfo.GetCoderOutStreamIndex(coderIndex);
    if (coder.Coder == null)
        return HRESULT.E_NOTIMPL;
    ICompressSetOutStream setOutStream = null;
    try {
        // coder.Coder.QueryInterface(IID_ICompressSetOutStream, &setOutStream);
        setOutStream = (ICompressSetOutStream) coder.Coder;
    } catch (java.lang.ClassCastException e) {
        return HRESULT.E_NOTIMPL;
    }
    if (coder.NumOutStreams > 1)
        return HRESULT.E_NOTIMPL;
    for (i = 0; i < (int) coder.NumOutStreams; i++) {
        java.io.OutputStream[] tmp = new java.io.OutputStream[1];
        int res = GetOutStream(outStreams, useless_outSizes, startIndex + i, tmp);
        if (res != HRESULT.S_OK)
            return res;
        java.io.OutputStream seqOutStream2 = tmp[0];
        res = setOutStream.SetOutStream(seqOutStream2);
        if (res != HRESULT.S_OK)
            return res;
    }
    // seqOutStream.Detach();
    outStreamRes[0] = seqOutStream;
    return HRESULT.S_OK;
}
Example 58
Project: MyPublicRepo-master  File: PseudoOperationUtil.java View source code
public static boolean streamResource(String resourceName, OutputStream outputStream, ClassLoader classLoader) throws IOException, ServiceException {
    InputStream input = classLoader.getResourceAsStream(resourceName);
    if (input == null) {
        input = classLoader.getResourceAsStream(resourceName);
        if (input == null) {
            return false;
        }
    }
    byte[] buf = new byte[8192];
    int numRead = 0;
    while ((numRead = input.read(buf)) != -1) {
        outputStream.write(buf, 0, numRead);
    }
    return true;
}
Example 59
Project: OpenCDC-master  File: SocketServer.java View source code
public static void main(String[] args) throws Exception {
    ServerSocket server = new ServerSocket(5566);
    //		socket.setSendBufferSize(1000);
    Socket socket = server.accept();
    server.setReceiveBufferSize(44);
    socket.setSendBufferSize(44);
    InputStream is = socket.getInputStream();
    OutputStream os = socket.getOutputStream();
    while (true) {
        os.write(new byte[60]);
        TimeUnit.SECONDS.sleep(2);
        os.write(new byte[12]);
    }
}
Example 60
Project: PoiParser-master  File: AnnotatedWritePoiParserFactoryTest.java View source code
@Test
public void testCreateWritePoiParser() {
    final OutputStream mockOutputStream = Mockito.mock(OutputStream.class);
    AnnotatedWritePoiParserFactory annotatedWritePoiParserFactory = new AnnotatedWritePoiParserFactory();
    WritePoiParser annotatedWritePoiParser = annotatedWritePoiParserFactory.createWritePoiParser(mockOutputStream);
    Assert.assertNotNull("Annotated writer poi parser cannot be null", annotatedWritePoiParser);
}
Example 61
Project: sandboxes-master  File: FirstDoc.java View source code
public static void main(String[] args) throws IOException, DocumentException {
    URL baseLocation = FirstDoc.class.getProtectionDomain().getCodeSource().getLocation();
    URL location = new URL(baseLocation, "firstdoc.xhtml");
    String outputFile = "firstdoc.pdf";
    OutputStream os = new FileOutputStream(outputFile);
    ITextRenderer renderer = new ITextRenderer();
    renderer.setDocument(location.toExternalForm());
    renderer.layout();
    renderer.createPDF(os);
    os.close();
}
Example 62
Project: simpleframework-master  File: WebSocketTestClient.java View source code
public static void main(String[] list) throws Exception {
    Socket socket = new Socket("localhost", 80);
    OutputStream out = socket.getOutputStream();
    byte[] request = ("GET / HTTP/1.0\r\n\r\n").getBytes("ISO-8859-1");
    out.write(request);
    InputStream in = socket.getInputStream();
    byte[] chunk = new byte[1024];
    int count = 0;
    while ((count = in.read(chunk)) != -1) {
        Thread.sleep(1000);
        System.err.write(chunk, 0, count);
    }
}
Example 63
Project: siu-master  File: TransformC14Exclusive.java View source code
public static XMLSignatureInput performTransform(XMLSignatureInput input, OutputStream os) throws CanonicalizationException {
    Canonicalizer20010315ExclOmitComments c14n = new Canonicalizer20010315ExclOmitComments();
    if (os != null) {
        c14n.setWriter(os);
    }
    byte[] result = c14n.engineCanonicalize(input, null);
    XMLSignatureInput output = new XMLSignatureInput(result);
    if (os != null) {
        output.setOutputStream(os);
    }
    return output;
}
Example 64
Project: TagRec-master  File: ResultSerializer.java View source code
public static void serializePredictions(Map<Integer, Map<Integer, Double>> predictions, String filePath) {
    OutputStream file = null;
    try {
        file = new FileOutputStream(filePath);
        OutputStream buffer = new BufferedOutputStream(file);
        ObjectOutput output = new ObjectOutputStream(buffer);
        output.writeObject(predictions);
        output.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 65
Project: test-driven-javascript-example-application-master  File: LatestVersionResult.java View source code
public void execute(ActionInvocation invocation) throws Exception {
    LatestVersionSource source = (LatestVersionSource) invocation.getAction();
    double latestVersion = source.getLatestVersion();
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setContentType("text/xml");
    OutputStream out = response.getOutputStream();
    out.write(String.valueOf(latestVersion).getBytes());
    out.close();
}
Example 66
Project: Testing-and-Debugging-JavaScript-master  File: LatestVersionResult.java View source code
public void execute(ActionInvocation invocation) throws Exception {
    LatestVersionSource source = (LatestVersionSource) invocation.getAction();
    double latestVersion = source.getLatestVersion();
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setContentType("text/xml");
    OutputStream out = response.getOutputStream();
    out.write(String.valueOf(latestVersion).getBytes());
    out.close();
}
Example 67
Project: turmeric-runtime-master  File: PseudoOperationUtil.java View source code
public static boolean streamResource(String resourceName, OutputStream outputStream, ClassLoader classLoader) throws IOException, ServiceException {
    InputStream input = classLoader.getResourceAsStream(resourceName);
    if (input == null) {
        input = classLoader.getResourceAsStream(resourceName);
        if (input == null) {
            return false;
        }
    }
    byte[] buf = new byte[8192];
    int numRead = 0;
    while ((numRead = input.read(buf)) != -1) {
        outputStream.write(buf, 0, numRead);
    }
    return true;
}
Example 68
Project: cmake4cdt-master  File: CommandLauncherRC.java View source code
/* (non-Javadoc)
	 * @see org.eclipse.cdt.core.ICommandLauncher#waitAndRead(java.io.OutputStream, java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor)
	 */
@Override
public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) {
    if (fShowCommand) {
        printCommandLine(output);
    }
    if (fProcess == null) {
        return ICommandLauncher.ILLEGAL_COMMAND;
    }
    ProcessClosure closure = new ProcessClosure(fProcess, output, err);
    closure.runNonBlocking();
    while (!monitor.isCanceled() && closure.isAlive()) {
        try {
            Thread.sleep(DELAY);
        } catch (InterruptedException ie) {
        }
    }
    int state = ICommandLauncher.OK;
    // Operation canceled by the user, terminate abnormally.
    if (monitor.isCanceled()) {
        closure.terminate();
        state = ICommandLauncher.COMMAND_CANCELED;
        setErrorMessage(Messages.CommandLauncher_CommandCancelled);
    }
    try {
        state = fProcess.waitFor();
    } catch (InterruptedException e) {
    }
    return state;
}
Example 69
Project: debop4j-master  File: StreamTool.java View source code
/**
     * [email protected] java.io.InputStream} ë‚´ìš©ì?„ ì?½ì–´, [email protected] java.io.OutputStream} ì—? ì”?니다.
     *
     * @param inputStream  �본 스트림
     * @param outputStream 대� 스트림
     * @return 복사한 ��터 길�
     * @throws java.io.IOException
     */
public static long copy(final InputStream inputStream, final OutputStream outputStream) throws IOException {
    shouldNotBeNull(inputStream, "inputStream");
    shouldNotBeNull(outputStream, "outputStream");
    byte[] buffer = new byte[BUFFER_SIZE];
    int n;
    long size = 0;
    while ((n = inputStream.read(buffer, 0, BUFFER_SIZE)) > 0) {
        outputStream.write(buffer, 0, n);
        size += n;
    }
    //Streams.copy(inputStream, outputStream, buffer);
    return size;
}
Example 70
Project: railo-master  File: CFCProxy.java View source code
private Object _invoke(String methodName, Object[] args, HttpServletRequest req, HttpServletResponse rsp, OutputStream out) throws PageException {
    CFMLEngine engine = CFMLEngineFactory.getInstance();
    Creation creator = engine.getCreationUtil();
    PageContext originalPC = engine.getThreadPageContext();
    // no OutputStream
    if (out == null)
        out = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM;
    // no Request
    if (req == null) {
        // TODO new File
        req = creator.createHttpServletRequest(new File("."), "Railo", "/", "", null, null, null, null, null);
    }
    // noRespone
    if (rsp == null) {
        rsp = creator.createHttpServletResponse(out);
    }
    PageContext pc = creator.createPageContext(req, rsp, out);
    try {
        engine.registerThreadPageContext(pc);
        initCFC(pc);
        return cfc.call(pc, methodName, args);
    } finally {
        if (autoFlush) {
            try {
                pc.getRootWriter().flush();
            } catch (Throwable t) {
            }
        }
        engine.registerThreadPageContext(originalPC);
    }
}
Example 71
Project: webtools.javaee-master  File: ZipStreamSaveStrategyImpl.java View source code
/**
	 * @see com.ibm.etools.archive.SaveStrategy#saveMofResource(Resource)
	 */
@Override
public void saveMofResource(Resource aResource, OutputStream out) throws IOException {
    Revisit.revisit();
    URI uri = aResource.getURI();
    //Ensure container relative URI
    URIConverter conv = getArchive().getResourceSet().getURIConverter();
    if (conv instanceof CompatibilityURIConverter)
        uri = ((CompatibilityURIConverter) conv).deNormalize(uri);
    ZipEntry entry = new ZipEntry(uri.toString());
    zipOutputStream.putNextEntry(entry);
    super.saveMofResource(aResource, out);
    zipOutputStream.closeEntry();
}
Example 72
Project: 3f-lab-master  File: Main.java View source code
public java.io.OutputStream openOutputStream(String user, boolean secure) throws IOException, NoSuchAlgorithmException {
    FTPClient ftp = !secure ? new FTPClient() : new FTPSClient("TLS");
    System.out.println(user);
    System.out.println(secure);
    String host = props.getProperty(user + ".host");
    String login = props.getProperty(user + ".login");
    String passwd = props.getProperty(user + ".passwd");
    String dir = props.getProperty(user + ".dir");
    String fileName = props.getProperty(user + ".file");
    ftp.connect(host);
    ftp.login(login, passwd);
    ftp.enterLocalPassiveMode();
    ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
    OutputStream out = ftp.storeFileStream(dir + '/' + fileName);
    //  new Thread(new Closer(ftp, out)).start();
    System.out.println("FTP stream is open" + (secure ? " (secure)." : "."));
    return out;
}
Example 73
Project: activityinfo-master  File: JaxRsIO.java View source code
public static Response stream(final InputStream is) {
    StreamingOutput stream = new StreamingOutput() {

        @Override
        public void write(OutputStream os) throws IOException, WebApplicationException {
            try {
                int n;
                byte[] buffer = new byte[1024];
                while ((n = is.read(buffer)) > -1) {
                    os.write(buffer, 0, n);
                }
                os.close();
            } catch (Exception e) {
                throw new WebApplicationException(e);
            }
        }
    };
    return Response.ok(stream).build();
}
Example 74
Project: Android_H264Stream-master  File: WorkerRunnable.java View source code
@Override
public void run() {
    try {
        InputStream input = clientSocket.getInputStream();
        OutputStream output = clientSocket.getOutputStream();
        long time = System.currentTimeMillis();
        output.write(("HTTP/1.1 200 OK\n\nWorkerRunnable: " + this.serverText + " - " + time + "").getBytes());
        output.close();
        input.close();
        System.out.println("Request processed: " + time);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 75
Project: Aspose_BarCode_Java-master  File: RenderBarcodeToServlet.java View source code
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    BarCodeBuilder b = new BarCodeBuilder();
    b.setSymbologyType(Symbology.Code128);
    b.setCodeText("12345678");
    BufferedImage image = b.getBarCodeImage();
    response.setContentType("image/png");
    OutputStream outputStream = response.getOutputStream();
    ImageIO.write(image, "png", outputStream);
    outputStream.close();
}
Example 76
Project: Aspose_for_Apache_POI-master  File: ApacheAttachments.java View source code
public static void main(String[] args) throws Exception {
    MAPIMessage msg = new MAPIMessage("data/message.msg");
    AttachmentChunks[] attachments = msg.getAttachmentFiles();
    if (attachments.length > 0) {
        File d = new File("data/attachments");
        if (d.exists() || d.mkdir()) {
            for (AttachmentChunks attachment : attachments) {
                String fileName = attachment.attachFileName.toString();
                if (attachment.attachLongFileName != null) {
                    fileName = attachment.attachLongFileName.toString();
                }
                File f = new File(d, fileName);
                OutputStream fileOut = null;
                try {
                    fileOut = new FileOutputStream(f);
                    fileOut.write(attachment.attachData.getValue());
                } finally {
                    if (fileOut != null) {
                        fileOut.close();
                    }
                }
            }
        }
    }
    System.out.println("Done ...");
}
Example 77
Project: atlas-lb-master  File: EncryptedPrivateKeyInfoBuilder.java View source code
public EncryptedPrivateKeyInfoHolder build(OutputEncryptor encryptor) {
    try {
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        OutputStream cOut = encryptor.getOutputStream(bOut);
        cOut.write(privateKeyInfo.getEncoded());
        cOut.close();
        return new EncryptedPrivateKeyInfoHolder(new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray()));
    } catch (IOException e) {
        throw new IllegalStateException("cannot encode privateKeyInfo");
    }
}
Example 78
Project: atom-hopper-master  File: AtomHopperServerControl.java View source code
public void stopAtomHopper() {
    try {
        Socket s = new Socket(InetAddress.getByName(LOCALHOST_IP), commandLineArgs.stopport);
        OutputStream out = s.getOutputStream();
        LOG.info("Sending Atom Hopper stop request");
        out.write(("\r\n").getBytes());
        out.flush();
        s.close();
    } catch (IOException ioex) {
        LOG.error("An error occured while attempting to stop Atom Hopper: " + ioex.getMessage());
    }
}
Example 79
Project: available-master  File: TestFactoryClient.java View source code
@Ignore
@Test
public void testSendMsg() throws UnknownHostException, IOException, InterruptedException {
    Socket socket = new Socket("127.0.0.1", 5551);
    OutputStream os = socket.getOutputStream();
    DataOutputStream dos = new DataOutputStream(os);
    //		dos.write("hello".length());
    for (int i = 0; i < 10; i++) {
        dos.writeInt("hah".length());
        dos.write("hah".getBytes());
    }
    //		writer.write("hello".getBytes());
    //		OutputStreamWriter writer = new OutputStreamWriter(dos);
    //		writer.flush();
    TimeUnit.SECONDS.sleep(50);
}
Example 80
Project: BamQC-master  File: ImageToBase64.java View source code
public static String imageToBase64(BufferedImage b) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    OutputStream b64 = new Base64.OutputStream(os);
    try {
        ImageIO.write(b, "PNG", b64);
        return ("data:image/png;base64," + os.toString("UTF-8"));
    } catch (IOException e) {
        log.error("Failed", e);
        return "Failed";
    }
}
Example 81
Project: BBAW_CMS-master  File: ResourceWriter.java View source code
public OutputStream write(final String outputUrl) throws ApplicationException {
    File outputFile = new File(outputUrl);
    File dir = outputFile.getParentFile();
    try {
        dir.mkdirs();
        outputFile.createNewFile();
        return new FileOutputStream(outputFile);
    } catch (IOException e) {
        throw new ApplicationException("Problem while creating output stream for the specified file " + outputUrl);
    }
}
Example 82
Project: bbssh-master  File: HttpOutboundStream.java View source code
public void flush() throws IOException {
    super.flush();
    HttpConnection outbound = (HttpConnection) Connector.open(url, Connector.READ_WRITE, false);
    outbound.setRequestMethod(HttpConnection.POST);
    OutputStream out = outbound.openOutputStream();
    out.write(toByteArray());
    out.close();
    outbound.openInputStream().close();
    reset();
}
Example 83
Project: BeeFramework_Android-master  File: Transmitter.java View source code
public static void transmit(Command c, Map h, String b, java.io.OutputStream out) throws IOException {
    StringBuffer message = new StringBuffer(c.toString());
    message.append("\n");
    if (h != null) {
        for (Iterator keys = h.keySet().iterator(); keys.hasNext(); ) {
            String key = (String) keys.next();
            String value = (String) h.get(key);
            message.append(key);
            message.append(":");
            message.append(value);
            message.append("\n");
        }
    }
    message.append("\n");
    if (b != null)
        message.append(b);
    message.append("\000");
    out.write(message.toString().getBytes(Command.ENCODING));
}
Example 84
Project: ciel-java-master  File: SkyhoutTask.java View source code
@Override
public void invoke(InputStream[] fis, OutputStream[] fos, String[] args) {
    try {
        Configuration conf = new Configuration();
        conf.setClassLoader(JarTaskLoader.CLASSLOADER);
        conf.setClass("io.serializations", WritableSerialization.class, Serialization.class);
        SkywritingTaskFileSystem fs = new SkywritingTaskFileSystem(fis, fos, conf);
        this.invoke(fs, args);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
Example 85
Project: codeine-master  File: SocketUtils.java View source code
public static void sendToPort(String hostPort, String value) {
    String[] splittd = hostPort.split(":");
    Socket socket = null;
    try {
        socket = new Socket(splittd[0], Integer.valueOf(splittd[1]));
        OutputStream out = socket.getOutputStream();
        out.write(value.getBytes());
        out.flush();
        out.close();
    } catch (Exception e) {
        throw ExceptionUtils.asUnchecked(e);
    } finally {
        try {
            socket.close();
        } catch (IOException e) {
            log.info("failed to close socket " + e.getMessage());
        }
    }
}
Example 86
Project: commcare-odk-master  File: AndroidStreamUtil.java View source code
/**
     * Write is to os and close both
     * @param is
     * @param os
     */
public static void writeFromInputToOutput(InputStream is, OutputStream os) throws IOException {
    byte[] buffer = new byte[8192];
    try {
        int count = is.read(buffer);
        while (count != -1) {
            os.write(buffer, 0, count);
            count = is.read(buffer);
        }
    } finally {
        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            os.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Example 87
Project: common-java-cookbook-master  File: CloseFlushExample2.java View source code
public static void main(String[] args) {
    OutputStream os = null;
    try {
        os = new FileOutputStream(new File("data", "output.txt"));
        // Do something fantastic with this file!!!
        // etc.
        byte magnificentByte = 1;
        os.write(magnificentByte);
    } catch (FileNotFoundException fnfe) {
    } catch (IOException ioe) {
    } finally {
        try {
            if (os != null) {
                os.flush();
                os.close();
            }
        } catch (IOException e) {
        }
    }
}
Example 88
Project: constellio-master  File: AppManagementServiceDownload.java View source code
@Override
public void run() {
    result = true;
    try {
        OutputStream warFileOutput = destination.create("war upload");
        byte[] buffer = new byte[8 * 1024];
        try {
            int bytesRead;
            while ((bytesRead = download.read(buffer)) != -1) {
                warFileOutput.write(buffer, 0, bytesRead);
            }
        } finally {
            warFileOutput.close();
        }
    } catch (IOException ioe) {
        result = false;
    }
}
Example 89
Project: Containing-master  File: WorkerRunnable.java View source code
public void run() {
    try {
        InputStream input = clientSocket.getInputStream();
        OutputStream output = clientSocket.getOutputStream();
        long time = System.currentTimeMillis();
        output.write(("HTTP/1.1 200 OK\n\nWorkerRunnable: " + this.serverText + " - " + time + "").getBytes());
        output.close();
        input.close();
        System.out.println("Request processed: " + time);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 90
Project: cooper-master  File: CohesionSubJDependUnitDialog.java View source code
private void printCohesion(SubJDependUnit unit) {
    OutputStream info = new ByteArrayOutputStream();
    JDependPrinter printer = new JDependPrinter();
    printer.setStream(info);
    printer.printSubJDependUnitCohesion(unit);
    printer.getWriter().flush();
    cohesionText = new StringBuilder(info.toString());
    try {
        info.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 91
Project: cotta-master  File: OutputTest.java View source code
public void testWithStaticFactorySupportsPath() throws TIoException {
    OutputStream stream = new ByteArrayOutputStream();
    Output.with(stream).write(new OutputProcessor() {

        public void process(OutputManager manager) throws IOException {
            try {
                manager.writer("aoeuaoeuaoeu");
                fail("should have thrown exception for wrong encoding");
            } catch (TIoException e) {
                ensure.that(e).message().contains("output stream");
            }
        }
    });
}
Example 92
Project: count-db-master  File: VirtualFileService.java View source code
public void storeSingleObject(String location, Object object) {
    VirtualFile file = getFile(location);
    try (OutputStream os = file.createOutputStream()) {
        SerializationUtils.writeObject(object, os);
    } catch (IOException exp) {
        throw new RuntimeException("Unexpected exception while trying to write object to " + location);
    }
}
Example 93
Project: Crud2Go-master  File: Utils.java View source code
public static void fastCopy(InputStream input, OutputStream output) throws IOException {
    ReadableByteChannel src = Channels.newChannel(input);
    WritableByteChannel dest = Channels.newChannel(output);
    ByteBuffer buffer = ByteBuffer.allocateDirect(16 * 1024);
    while (src.read(buffer) != -1) {
        buffer.flip();
        dest.write(buffer);
        buffer.compact();
    }
    buffer.flip();
    while (buffer.hasRemaining()) {
        dest.write(buffer);
    }
    src.close();
    dest.close();
}
Example 94
Project: dashreports-master  File: TextToImageTest.java View source code
public void testGetImageForText() {
    try {
        TextToImage t = new TextToImage();
        byte[] ba = t.getImageForText(new String[] { "Line 1", "Line 2", "Line 3" }, Color.WHITE, Color.BLACK, new Font("Serif", Font.PLAIN, 12), 400, 100, 10, 20, ImageFileFormat.PNG);
        File file = new File("test.png");
        if (file.exists())
            file.delete();
        OutputStream os = new FileOutputStream(file);
        os.write(ba);
        os.flush();
        os.close();
        System.out.println(file.getAbsolutePath());
        assertTrue(ba.length > 10);
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Example 95
Project: dataservices-sdk-java-master  File: ResetUidSecretRequest.java View source code
public ResetUidSecretResponse call() throws Exception {
    HttpURLConnection con = getConnection("/sub_tenant_admin/add_application", MessageFormat.format("app_name={0}&sub_tenant_name={1}®enerate=yes", uid, subTenantName));
    con.setDoOutput(true);
    con.connect();
    OutputStream out = con.getOutputStream();
    out.close();
    return new ResetUidSecretResponse(con);
}
Example 96
Project: document-management-master  File: CeasrTestApp.java View source code
public static void main(String[] args) throws Exception {
    OutputStream os = new FileOutputStream("/home/maciuch/tmp/topsecret.txt");
    int k = 255;
    os = new CesarOutputStream(os, k);
    os.write("Ala ma psa".getBytes());
    os.close();
    InputStream is = new FileInputStream("/home/maciuch/tmp/topsecret.txt");
    is = new CesarInputStream(is, k);
    int b;
    StringBuilder sb = new StringBuilder();
    while ((b = is.read()) != -1) {
        sb.append((char) b);
    }
    System.out.println(sb.toString());
}
Example 97
Project: elasticsearch-plugin-bundle-master  File: FstCompilerTool.java View source code
@Test
@Ignore
public void buildFstDecompound() throws IOException {
    FstCompiler fstCompiler = new FstCompiler();
    Path path = Paths.get("build/words.fst");
    try (InputStream inputStream = new GZIPInputStream(getClass().getResource("morphy.txt.gz").openStream());
        OutputStream outputStream = Files.newOutputStream(path)) {
        fstCompiler.compile(inputStream, outputStream);
    }
}
Example 98
Project: email-master  File: ProgressBodyFactory.java View source code
@Override
protected void copyData(InputStream inputStream, OutputStream outputStream) throws IOException {
    final CountingOutputStream countingOutputStream = new CountingOutputStream(outputStream);
    Timer timer = new Timer();
    try {
        timer.scheduleAtFixedRate(new TimerTask() {

            @Override
            public void run() {
                progressListener.updateProgress(countingOutputStream.getCount());
            }
        }, 0, 50);
        super.copyData(inputStream, countingOutputStream);
    } finally {
        timer.cancel();
    }
}
Example 99
Project: epicsarchiverap-master  File: GetPolicyText.java View source code
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp, ConfigService configService) throws IOException {
    try (InputStream is = configService.getPolicyText()) {
        resp.setContentType("text/plain");
        try (OutputStream os = resp.getOutputStream()) {
            byte[] buf = new byte[10 * 1024];
            int bytesRead = is.read(buf);
            while (bytesRead > 0) {
                os.write(buf, 0, bytesRead);
                bytesRead = is.read(buf);
            }
        }
    }
}
Example 100
Project: ExcelTool-master  File: TestExtend.java View source code
@Test
public void test() throws WriteException, FileNotFoundException {
    ExtendUtil extendUtil = new ExtendUtil();
    List<TestBean> beanList = new ArrayList<TestBean>();
    for (int i = 0; i < 3000; i++) {
        TestBean bean = new TestBean();
        bean.setIntTest(10000000);
        bean.setStrTest("努力造轮�");
        bean.setTimeTest(new Timestamp(System.currentTimeMillis()));
        beanList.add(bean);
    }
    OutputStream out = new FileOutputStream("d:/yy-export-excel/test3.xls");
    extendUtil.exportByAnnotation(out, beanList);
}
Example 101
Project: filebot-master  File: FileMapper.java View source code
@Override
public OutputStream getStream(File entry) throws IOException {
    File outputFile = getOutputFile(entry);
    File outputFolder = outputFile.getParentFile();
    // create parent folder if necessary
    if (!outputFolder.isDirectory() && !outputFolder.mkdirs()) {
        throw new IOException("Failed to create folder: " + outputFolder);
    }
    return new FileOutputStream(outputFile);
}