com.sun.xml.messaging.saaj.packaging.mime.util.OutputUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of saaj-impl Show documentation
Show all versions of saaj-impl Show documentation
Open source Reference Implementation of JSR-67: SOAP with Attachments API for Java (SAAJ MR: 1.4)
The newest version!
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* @(#)OutputUtil.java 1.6 02/03/27
*/
package com.sun.xml.messaging.saaj.packaging.mime.util;
import java.io.OutputStream;
import java.io.IOException;
/**
* This class is to support writing out Strings as a sequence of bytes
* terminated by a CRLF sequence. The String must contain only US-ASCII
* characters.
*
* The expected use is to write out RFC822 style headers to an output
* stream.
*
* @author Kohsuke Kawaguchi
*/
public final class OutputUtil {
private static byte[] newline = {'\r','\n'};
private OutputUtil() {}
public static void writeln(String s,OutputStream out) throws IOException {
writeAsAscii(s,out);
writeln(out);
}
/**
* Writes a string as ASCII string.
*
* @param s string.
* @param out output stream.
*
* @throws IOException if an I/O error occurs.
*/
public static void writeAsAscii(String s,OutputStream out) throws IOException {
int len = s.length();
for( int i=0; i