當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。