当前位置: 首页>>代码示例>>Java>>正文


Java OutputStreamWriter.flush方法代码示例

本文整理汇总了Java中java.io.OutputStreamWriter.flush方法的典型用法代码示例。如果您正苦于以下问题:Java OutputStreamWriter.flush方法的具体用法?Java OutputStreamWriter.flush怎么用?Java OutputStreamWriter.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.OutputStreamWriter的用法示例。


在下文中一共展示了OutputStreamWriter.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: service

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
@Override
public void service(ServletRequest servletRequest, ServletResponse response) throws ServletException, IOException {
  ClientSettings settings = new ClientSettings(
      options.getOption(SupportService.SUPPORT_EMAIL_ADDR),
      options.getOption(SupportService.SUPPORT_EMAIL_SUBJECT),
      options.getOption(SupportService.OUTSIDE_COMMUNICATION_DISABLED),
      options.getOption(AccelerationOptions.ENABLE_SUBHOUR_POLICIES),
      options.getOption(UIOptions.ALLOW_LOWER_PROVISIONING_SETTINGS),
      options.getOption(UIOptions.TABLEAU_TDS_MIMETYPE));

  String environment = config.allowTestApis ? "DEVELOPMENT" : "PRODUCTION";
  final ServerData indexConfig = new ServerData(environment, serverHealthMonitor, config.getConfig(), settings, getVersionInfo(), supportService.getClusterId().getIdentity());

  Template tmp = templateCfg.getTemplate("/index.html");

  response.setContentType("text/html; charset=utf-8");
  OutputStreamWriter outputWriter = new OutputStreamWriter(response.getOutputStream());
  try {
    tmp.process(ImmutableMap.of("dremio", indexConfig), outputWriter);
    outputWriter.flush();
    outputWriter.close();
  } catch (TemplateException e) {
    throw new IOException("Error rendering index.html template", e);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:IndexServlet.java

示例2: post

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
public static String post(URLConnection connection,
                          String stringWriter,
                          Credentials credentials) throws Exception {

   connection.setDoInput(true);
   connection.setDoOutput(true);
   connection.setRequestProperty("Authorization",
                                 "Basic "
                                       + Base64.encode((credentials.getUserName() + ":" + new String(
                                             credentials.getPassword())).getBytes()));
   OutputStreamWriter postData = new OutputStreamWriter(connection.getOutputStream());
   postData.write(stringWriter);
   postData.flush();
   postData.close();

   BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
   String response = "";
   String line = "";
   while ((line = in.readLine()) != null)
      response = response + line;
   in.close();

   return response;
}
 
开发者ID:mqsysadmin,项目名称:dpdirect,代码行数:25,代码来源:PostXML.java

示例3: saveDocument

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
public static void saveDocument(Document doc, String filePath) {
    /**
     * @todo: Configurable parameters
     */
    try {
        /*The XOM bug: reserved characters are not escaped*/
        //Serializer serializer = new Serializer(new FileOutputStream(filePath), "UTF-8");
        //serializer.write(doc);
        OutputStreamWriter fw =
            new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8");
        fw.write(doc.toXML());
        fw.flush();
        fw.close();
    }
    catch (IOException ex) {
        new ExceptionDialog(
            ex,
            "Failed to write a document to " + filePath,
            "");
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:22,代码来源:FileStorage.java

示例4: createTopicsIfNecessary

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
public void createTopicsIfNecessary( String... topics ) throws Exception{
	SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
	sslContext.init(null, null, null);
	for( String topic : topics ){
		URL messageHubUrl = new URL( getConfig(MessageHubConfig.MESSAGEHUB_REST_URL) + "/admin/topics" );
		HttpsURLConnection con = (HttpsURLConnection) messageHubUrl.openConnection();
		con.setDoOutput(true);
		con.setDoInput(true);
		con.setRequestProperty("Content-Type", "application/json");
		con.setRequestProperty("X-Auth-Token", getConfig(MessageHubConfig.MESSAGEHUB_API_KEY));
		con.setRequestProperty("Accept", "application/json");
		con.setRequestMethod("POST");

		OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
		wr.write( "{\"name\":\"" + topic + "\"}" );
		wr.flush();

		int res = con.getResponseCode();
		switch (res){
		case 200:
		case 202:
			System.out.println("Successfully created topic: " + topic);
			break;            	   
		case 422:
		case 403: 
			System.out.println("Topic already exists in the server: " + topic);
			break;
		default:
			throw new IllegalStateException("Error when trying to create topic: " + res + " Reason: " + con.getResponseMessage());
		}
	}
}
 
开发者ID:ibm-watson-data-lab,项目名称:advo-beta-producer,代码行数:33,代码来源:MessageHubConfig.java

示例5: dump

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
/**
 * Ascii file dump.
 *
 * dumpFile must not be null.
 */
private void dump(String varName,
                  File dumpFile) throws IOException, BadSpecial {
    String val = (String) userVars.get(varName);

    if (val == null) {
        throw new BadSpecial(rb.getString(
                SqltoolRB.PLVAR_UNDEFINED, varName));
    }

    OutputStreamWriter osw = ((charset == null)
            ? (new OutputStreamWriter(new FileOutputStream(dumpFile)))
            : (new OutputStreamWriter(new FileOutputStream(dumpFile),
                        charset)));
    // Replace with just "(new FileOutputStream(file), charset)"
    // once use defaultCharset from Java 1.5 in charset init. above.

    try {
        osw.write(val);

        if (val.length() > 0) {
            char lastChar = val.charAt(val.length() - 1);

            if (lastChar != '\n' && lastChar != '\r') {
                osw.write(LS);
            }
        }

        osw.flush();
    } finally {
        osw.close();
    }

    // Since opened in overwrite mode, since we didn't exception out,
    // we can be confident that we wrote all the bytest in the file.
    stdprintln(rb.getString(SqltoolRB.FILE_WROTECHARS,
            Long.toString(dumpFile.length()), dumpFile.toString()));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:43,代码来源:SqlFile.java

示例6: a

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
private void a(String str, String str2) {
    try {
        if (this.d != null) {
            str = str + "." + this.d;
        }
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(this.c.openFileOutput
                (str, 0), Charset.forName("UTF-8"));
        outputStreamWriter.write(str2);
        outputStreamWriter.flush();
        outputStreamWriter.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:OpenConfig.java

示例7: convert

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
@Override public RequestBody convert(T value) throws IOException {
  Buffer buffer = new Buffer();
  try {
    OutputStreamWriter osw = new OutputStreamWriter(buffer.outputStream(), CHARSET);
    serializer.write(value, osw);
    osw.flush();
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
  return RequestBody.create(MEDIA_TYPE, buffer.readByteString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SimpleXmlRequestBodyConverter.java

示例8: writeTo

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
/**
 * Write the object to the output stream.
 */
public void writeTo(Object obj, String mimeType, OutputStream os)
                                            throws IOException {
    if (dch != null)
        dch.writeTo(obj, mimeType, os);
    else if (obj instanceof byte[])
        os.write((byte[])obj);
    else if (obj instanceof String) {
        OutputStreamWriter osw = new OutputStreamWriter(os);
        osw.write((String)obj);
        osw.flush();
    } else throw new UnsupportedDataTypeException(
            "no object DCH for MIME type " + this.mimeType);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:DataHandler.java

示例9: copy

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
/**
 * Serialize chars from a <code>Reader</code> to bytes on an
 * <code>OutputStream</code>, and flush the <code>OutputStream</code>.
 * @param input the <code>Reader</code> to read from
 * @param output the <code>OutputStream</code> to write to
 * @throws IOException In case of an I/O problem
 */
public static void copy(
        Reader input,
        OutputStream output)
            throws IOException {
    OutputStreamWriter out = new OutputStreamWriter(output);
    copy(input, out);
    // XXX Unless anyone is planning on rewriting OutputStreamWriter, we
    // have to flush here.
    out.flush();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:CopyUtils.java

示例10: getCompressedContents

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
private byte[] getCompressedContents() throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    GZIPOutputStream gzip = new GZIPOutputStream( baos );
    OutputStreamWriter out = new OutputStreamWriter( gzip );
    out.write( _responseText );
    out.flush();
    out.close();
    return baos.toByteArray();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:WebClientTest.java

示例11: sendButtonActionPerformed

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_sendButtonActionPerformed
{//GEN-HEADEREND:event_sendButtonActionPerformed
    try
    {
        // Construct data
        String data = URLEncoder.encode("messages", "UTF-8") + "=" + URLEncoder.encode(logTextarea.getText(), "UTF-8");
        // Send data
        URL url = new URL("http://unimozer.fisch.lu/boot.php?who=moenagade");
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(data);
        wr.flush();
        // Get the response
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
            // Process line... --> do nothing
        }
        wr.close();
        rd.close();
    } 
    catch (Exception ex)
    {
        // ignore
    }
    this.dispose();
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:29,代码来源:BootLogReport.java

示例12: printHTMLPage

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
public void printHTMLPage(Source source)
        throws UnsupportedEncodingException, IOException {
    List<StartTag> list = source.getAllStartTags(HTMLElementName.STYLE);
    Iterator<StartTag> iterator = list.iterator();
    String text = "";
    while (iterator.hasNext()) {
        final StartTag tag = iterator.next();
        final Segment s = new Segment(source, tag.getEnd(), tag
                .getElement().getEndTag().getBegin());
        text += s.toString();
    }
    Vector<ReplaceRight> rights = Style.getStyles(text, styles, counter);

    // генерація сторінки з оновленими стилями.

    list = source.getAllStartTags();
    iterator = list.iterator();
    StartTag startTag = null;
    while (iterator.hasNext()) {
        final StartTag st = iterator.next();
        if (HTMLElementName.BODY.equals(st.getName())) {
            startTag = st;
            break;
        }
    }
    if (startTag == null)
        return;

    final StartTag body = startTag;
    final OutputDocument document = new OutputDocument(source);
    while (iterator.hasNext()) {
        startTag = iterator.next();
        replaceAttrs(startTag, document, rights);
    }

    OutputStreamWriter writer = new OutputStreamWriter(this.out, "UTF-8");
    document.writeTo(writer, body.getEnd(), body.getElement().getEndTag()
            .getBegin());
    writer.flush();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:41,代码来源:Out.java

示例13: toXml

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
public static <T> String toXml(T object) {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    try {
        OutputStreamWriter osw = new OutputStreamWriter(byteArrayOutputStream);
        serializer.write(object, osw);
        osw.flush();
        osw.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return byteArrayOutputStream.toString();
}
 
开发者ID:SKT-ThingPlug,项目名称:thingplug-sdk-android,代码行数:13,代码来源:Converter.java

示例14: print

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
@Override
public void print(UnknownFieldSet fields, OutputStream output, Charset cs)
		throws IOException {
	OutputStreamWriter writer = new OutputStreamWriter(output, cs);
	print(fields, writer);
	writer.flush();
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:8,代码来源:AbstractCharBasedFormatter.java

示例15: cmd

import java.io.OutputStreamWriter; //导入方法依赖的package包/类
String[] cmd(String[] command, boolean isRoot, boolean retError)
{
	StringBuilder sb = new StringBuilder();
	StringBuilder sberr=new StringBuilder();
	String[]ret=new String[2];
	try
	{
		Process p ;
		if (isRoot)
		{
			p = Runtime.getRuntime().exec("su");
		}
		else
		{
			p = Runtime.getRuntime().exec("sh");
		}
		OutputStreamWriter osw = new OutputStreamWriter(p.getOutputStream(), "UTF-8");
		for (int i=0;i < command.length;i++)
		{
			osw.write(command[i] + "\n");
		}
		osw.write("exit\n");
		osw.flush();
		BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
		BufferedReader brerr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
		String lerr="";
		String l = "";
		while ((l = br.readLine()) != null)
		{
			sb.append(l);
		}
		ret[0] = sb.toString();
		while ((lerr = brerr.readLine()) != null)
		{
			sberr.append(lerr + "\n");
		}
		p.getErrorStream().close();
	}
	catch (IOException e)
	{
		e.printStackTrace();
		return null;
	}
	if (sberr.length() > 0)
	{
		sberr.deleteCharAt(sberr.length() - 1);
		ret[1] = sberr.toString();
	}
	if (retError)
	{
		if (!sberr.toString().equals(""))
		{
			toastText(getString(R.string.shell_error) + sberr.toString(), true);
		}
	}
	return ret;
}
 
开发者ID:nijigenirubasho,项目名称:mobiletailchanger,代码行数:58,代码来源:MainActivity.java


注:本文中的java.io.OutputStreamWriter.flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。