當前位置: 首頁>>代碼示例>>Java>>正文


Java PrintStream.write方法代碼示例

本文整理匯總了Java中java.io.PrintStream.write方法的典型用法代碼示例。如果您正苦於以下問題:Java PrintStream.write方法的具體用法?Java PrintStream.write怎麽用?Java PrintStream.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.PrintStream的用法示例。


在下文中一共展示了PrintStream.write方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hexDigit

import java.io.PrintStream; //導入方法依賴的package包/類
static void hexDigit(PrintStream p, byte x) {
    char c;

    c = (char) ((x >> 4) & 0xf);
    if (c > 9)
        c = (char) ((c-10) + 'A');
    else
        c = (char)(c + '0');
    p.write(c);
    c = (char) (x & 0xf);
    if (c > 9)
        c = (char)((c-10) + 'A');
    else
        c = (char)(c + '0');
    p.write(c);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:17,代碼來源:HexDumpEncoder.java

示例2: testBomUtf8

import java.io.PrintStream; //導入方法依賴的package包/類
@Test
public void testBomUtf8() throws Exception {
  // Simple .csv file with a UTF-8 BOM. Should read successfully
  File testFolder = tempDir.newFolder("testUtf8Folder");
  File testFile = new File(testFolder, "utf8.csv");
  PrintStream p = new PrintStream(testFile);
  p.write(ByteOrderMark.UTF_8.getBytes(), 0, ByteOrderMark.UTF_8.length());
  p.print("A,B\n");
  p.print("5,7\n");
  p.close();

  testBuilder()
    .sqlQuery(String.format("select * from table(dfs.`%s` (type => 'text', " +
      "fieldDelimiter => ',', lineDelimiter => '\n', extractHeader => true))",
      testFile.getAbsolutePath()))
    .unOrdered()
    .baselineColumns("A","B")
    .baselineValues("5", "7")
    .go();
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:21,代碼來源:TestNewTextReader.java

示例3: testErrorBomUtf16

import java.io.PrintStream; //導入方法依賴的package包/類
@Test
public void testErrorBomUtf16() throws Exception {
  // UTF-16 BOM should cause a dataReadError user exception
  File testFolder = tempDir.newFolder("testUtf16Folder");
  File testFile = new File(testFolder, "utf16.csv");
  PrintStream p = new PrintStream(testFile);
  p.write(ByteOrderMark.UTF_16LE.getBytes(), 0, ByteOrderMark.UTF_16LE.length());
  p.print("A,B\n");
  p.print("5,7\n");
  p.close();

  thrownException.expect(new UserExceptionMatcher(UserBitShared.DremioPBError.ErrorType.DATA_READ,
    "DATA_READ ERROR: UTF-16 files not supported"));
  // NB: using test() instead of testBuilder() because it unwraps the thrown RpcException and re-throws the
  // underlying UserException (which is then matched with the UserExceptionMatcher)
  test(String.format("select * from table(dfs.`%s` (type => 'text', " +
      "fieldDelimiter => ',', lineDelimiter => '\n', extractHeader => true))",
    testFile.getAbsolutePath()));
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:20,代碼來源:TestNewTextReader.java

示例4: createOkResponse

import java.io.PrintStream; //導入方法依賴的package包/類
private void createOkResponse(PrintStream output, byte[] bytes) throws IOException {
    // formatting response
    output.println("HTTP/1.0 200 OK");
    output.println("Content-Type: text/html");
    output.println("Content-Length: " + bytes.length);
    output.println();
    output.write(bytes);
    output.flush();
}
 
開發者ID:mipegir,項目名稱:RemoteLogcatLibrary,代碼行數:10,代碼來源:RemoteLogCatServer.java

示例5: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(@NonNull byte[] buf, int off, int len) {
    super.write(buf, off, len);
    if (streams != null) {
        for (PrintStream printStream : streams) {
            printStream.write(buf, off, len);
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:10,代碼來源:JavaApplication.java

示例6: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(final WarcRecord warcRecord, final long storePosition, final PrintStream out) throws IOException {
	out.print(warcRecord.getWarcTargetURI());
	out.write('\t');
	out.print(warcRecord.getWarcHeader(Name.WARC_PAYLOAD_DIGEST).getValue());
	out.write('\n');
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:8,代碼來源:URLDigestWriter.java

示例7: readContainerLogs

import java.io.PrintStream; //導入方法依賴的package包/類
private static void readContainerLogs(DataInputStream valueStream,
    PrintStream out, long logUploadedTime) throws IOException {
  byte[] buf = new byte[65535];

  String fileType = valueStream.readUTF();
  String fileLengthStr = valueStream.readUTF();
  long fileLength = Long.parseLong(fileLengthStr);
  out.print("LogType:");
  out.println(fileType);
  if (logUploadedTime != -1) {
    out.print("Log Upload Time:");
    out.println(Times.format(logUploadedTime));
  }
  out.print("LogLength:");
  out.println(fileLengthStr);
  out.println("Log Contents:");

  long curRead = 0;
  long pendingRead = fileLength - curRead;
  int toRead =
            pendingRead > buf.length ? buf.length : (int) pendingRead;
  int len = valueStream.read(buf, 0, toRead);
  while (len != -1 && curRead < fileLength) {
    out.write(buf, 0, len);
    curRead += len;

    pendingRead = fileLength - curRead;
    toRead =
              pendingRead > buf.length ? buf.length : (int) pendingRead;
    len = valueStream.read(buf, 0, toRead);
  }
  out.println("End of LogType:" + fileType);
  out.println("");
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:35,代碼來源:AggregatedLogFormat.java

示例8: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(final WarcRecord warcRecord, final long storePosition, final PrintStream out) throws IOException {
	if (repeatedSet.contains(storeIndexMask | storePosition)) return;

	out.print(warcRecord.getWarcTargetURI());
	out.print('\t');
	out.print(storePosition);
	out.write('\n');
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:10,代碼來源:URLPositionWriter.java

示例9: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(final WarcRecord warcRecord, final long storePosition, final PrintStream out) throws IOException {
	out.print(warcRecord.getWarcTargetURI());
	out.print('\t');
	out.print(warcRecord.getWarcHeader(Name.WARC_PAYLOAD_DIGEST).getValue());
	out.print('\t');
	out.print(((HttpResponseWarcRecord)warcRecord).getStatusLine().getStatusCode());
	out.print('\t');
	out.print(warcRecord.getWarcHeader(WarcHeader.Name.BUBING_IS_DUPLICATE));
	out.print('\t');
	out.print(((HttpResponseWarcRecord)warcRecord).getEntity().getContentLength());
	out.write('\n');
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:14,代碼來源:URLDigestStatusLengthWriter.java

示例10: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(final WarcRecord warcRecord, final long storePosition, final PrintStream out) throws IOException {
	out.print(constant);
	out.print('\t');
	out.print(storePosition);
	out.write('\t');
	out.print(warcRecord.getWarcTargetURI());
	out.write('\n');
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:10,代碼來源:ConstantPositionURLWriter.java

示例11: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(final WarcRecord warcRecord, final long storePosition, final PrintStream out) throws IOException {
	if (repeatedSet.contains(storeIndexMask | storePosition)) return;

	final boolean isDuplicate = warcRecord.getWarcHeader(Name.BUBING_IS_DUPLICATE) != null;

	out.print(warcRecord.getWarcTargetURI());
	out.print('\t');
	out.print(warcRecord.getWarcHeader(Name.WARC_PAYLOAD_DIGEST).getValue());
	out.print('\t');
	out.print(isDuplicate ? -1 : finalPosition++);
	out.write('\t');
	out.print(((HttpResponseWarcRecord)warcRecord).getStatusLine());
	out.write('\n');
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:16,代碼來源:URLDigestFinalPositionWriter.java

示例12: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(final WarcRecord warcRecord, final long storePosition, final PrintStream out) throws IOException {
	out.print(ft.format(warcRecord.getWarcDate()));
	out.write('\t');
	out.print(warcRecord.getWarcTargetURI());
	out.write('\n');
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:8,代碼來源:DateURLWriter.java

示例13: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(PrintStream out, String s) throws IOException {
	try { out.write(s.getBytes("UTF-8")); }
	catch (UnsupportedEncodingException uee) { uee.printStackTrace(); }
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:6,代碼來源:AbstractElement.java

示例14: render

import java.io.PrintStream; //導入方法依賴的package包/類
public long render(long count, PrintStream outStream, boolean toFile) {
    if (count != 0) {
        int currentCount = 0;
        int countPerIteration = RND_PER_REQUEST;

        String[] rndArray = null;
        long maxLength = -1;
        long columns = -1;
        long columnCounter = -1;
        long lineCount = 0;
        long maxLines = 0;

        while (currentCount < count) {
            int nextLength = currentCount + countPerIteration > count ? (int) (count - currentCount) : countPerIteration;
            if (rndArray == null || nextLength != rndArray.length) {
                rndArray = new String[nextLength];
            }
            randomGenerator.request(rndArray);

            if (maxLength <= 0) {
                maxLength = getMaxLength(rndArray);
                columns = getColumnCount(maxLength);
                columnCounter = columns;
            }

            if (maxLines <= 0) {
                maxLines = (long) ((double) count / (double) columns);
            }

            for (int i = 0; i < rndArray.length; i++) {
                String randomString = rndArray[i];
                try {
                    if (columns == 1) {
                        outStream.write(encoderFormat.asBytes(randomString));
                    } else {
                        outStream.write(encoderFormat.asBytes(String.format("%-" + maxLength + "s", randomString)));
                    }

                    columnCounter--;

                    if (columnCounter == 0 && i + 1 != count) {
                        columnCounter = columns;
                        outStream.write(encoderFormat.asBytes(toFile ? encoderFormat.newLineFile() : encoderFormat.newLineCmdLine()));
                        lineCount++;

                        if (lineCount % LINE_BREAK_EVERY_LINES == 0 && (maxLines - lineCount > LINE_BREAK_EVERY_LINES / 2)) {
                            outStream.write(encoderFormat.asBytes(toFile ? encoderFormat.paragraphFile() : encoderFormat.paragraphCmdLine()));
                        }

                    } else {
                        outStream.write(encoderFormat.asBytes(toFile ? encoderFormat.separatorFile() : encoderFormat.separatorFile()));
                    }
                } catch (Exception e) {
                    throw new IllegalStateException("could not write random to output stream", e);
                }
            }
            currentCount += rndArray.length;
        }
    }
    return count;
}
 
開發者ID:patrickfav,項目名稱:dice,代碼行數:62,代碼來源:ColumnRenderer.java

示例15: write

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public void write(final Object processedRecord, final long storePosition, final PrintStream out) throws IOException {
	out.write(processedRecord.toString().getBytes(Charsets.UTF_8));
	out.write('\n');
}
 
開發者ID:LAW-Unimi,項目名稱:BUbiNG,代碼行數:6,代碼來源:ToStringWriter.java


注:本文中的java.io.PrintStream.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。