当前位置: 首页>>代码示例>>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;未经允许,请勿转载。