java.io.PrintStream.write()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中java.io.PrintStream.write()方法的一些代码示例,展示了PrintStream.write()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PrintStream.write()方法的具体详情如下:
包路径:java.io.PrintStream
类名称:PrintStream
方法名:write

PrintStream.write介绍

[英]Writes one byte to the target stream. Only the least significant byte of the integer oneByte is written. This stream is flushed if oneByte is equal to the character '\n' and this stream is set to autoFlush.

This stream's error flag is set to true if it is closed or an I/O error occurs.
[中]将一个字节写入目标流。只写入整数一字节中的最低有效字节。如果一个字节等于字符“\n”,并且此流设置为自动刷新,则会刷新此流。
如果流已关闭或发生I/O错误,则该流的错误标志将设置为true。

代码示例

代码示例来源:origin: log4j/log4j

public void write(final byte[] b, final int off, final int len)
  throws IOException {
  System.err.write(b, off, len);
}

代码示例来源:origin: log4j/log4j

public void write(final int b) throws IOException {
    System.err.write(b);
  }
}

代码示例来源:origin: log4j/log4j

public void write(final int b) throws IOException {
    System.out.write(b);
  }
}

代码示例来源:origin: log4j/log4j

public void write(final byte[] b, final int off, final int len)
  throws IOException {
  System.out.write(b, off, len);
}

代码示例来源:origin: log4j/log4j

public void write(final byte[] b) throws IOException {
  System.err.write(b);
}

代码示例来源:origin: log4j/log4j

public void write(final byte[] b) throws IOException {
  System.out.write(b);
}

代码示例来源:origin: spockframework/spock

@Override
 public void write(byte[] b) throws IOException {
  for (PrintStream stream : delegates) {
   stream.write(b);
  }
 }
}

代码示例来源:origin: spockframework/spock

@Override
public void write(int b) {
 for (PrintStream stream : delegates) {
  stream.write(b);
 }
}

代码示例来源:origin: spockframework/spock

@Override
public void write(byte[] buf, int off, int len) {
 for (PrintStream stream : delegates) {
  stream.write(buf, off, len);
 }
}

代码示例来源:origin: EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

@Override
public void output(final String output) throws IOException {
  System.out.write(output.getBytes());
  System.out.flush();
}

代码示例来源:origin: EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

@Override
public void output(final String output) throws IOException {
  System.out.write(output.getBytes());
  System.out.flush();
}

代码示例来源:origin: AxonFramework/AxonFramework

private void writeDownloadMessage() {
  try (InputStream in = getClass().getClassLoader().getResourceAsStream("axonserver_download.txt")) {
    byte[] buffer = new byte[1024];
    int read;
    while ((read = in.read(buffer, 0, 1024)) >= 0) {
      System.out.write(buffer, 0, read);
    }
  } catch (IOException e) {
    logger.debug("Unable to write download advice. You're on your own now.", e);
  }
}

代码示例来源:origin: apache/incubator-pinot

@Override
public void copyFromLocalFile(File srcFile, URI dstUri)
  throws Exception {
 OutputStream stream = _adlStoreClient.createFile(dstUri.getPath(), IfExists.OVERWRITE);
 PrintStream out = new PrintStream(stream);
 byte[] inputStream = IOUtils.toByteArray(new FileInputStream(srcFile));
 out.write(inputStream);
 out.close();
}

代码示例来源:origin: apache/maven

@Override
public void write( byte b[], int off, int len )
{
  final PrintStream currentStream = getOutputStreamForCurrentThread();
  synchronized ( currentStream )
  {
    currentStream.write( b, off, len );
    currentStream.notifyAll();
  }
}

代码示例来源:origin: apache/maven

@Override
  public void write( byte b[] )
    throws IOException
  {
    final PrintStream currentStream = getOutputStreamForCurrentThread();
    synchronized ( currentStream )
    {
      currentStream.write( b );
      currentStream.notifyAll();
    }
  }
}

代码示例来源:origin: commons-io/commons-io

public static void checkWrite(final OutputStream output) throws Exception {
  try {
    new java.io.PrintStream(output).write(0);
  } catch (final Throwable t) {
    throw new AssertionFailedError(
        "The copy() method closed the stream "
            + "when it shouldn't have. "
            + t.getMessage());
  }
}

代码示例来源:origin: twosigma/beakerx

private synchronized void writeStderr(String text) throws IOException {
 boolean sendStderr = OutputManager.sendStderr(text);
 if (!sendStderr) {
  BeakerOutputHandlers hrs = handlers.get(Thread.currentThread().getThreadGroup());
  if (hrs != null && hrs.err_handler != null) {
   hrs.err_handler.write(text);
  } else {
   orig_err.write(text.getBytes(StandardCharsets.UTF_8));
  }
 }
}

代码示例来源:origin: twosigma/beakerx

private synchronized void writeStdout(String text) throws IOException {
 boolean sendStdout = OutputManager.sendStdout(text);
 if (!sendStdout) {
  BeakerOutputHandlers hrs = handlers.get(Thread.currentThread().getThreadGroup());
  if (hrs != null && hrs.out_handler != null) {
   hrs.out_handler.write(text);
  } else {
   orig_out.write(text.getBytes(StandardCharsets.UTF_8));
  }
 }
}

代码示例来源:origin: iBotPeaches/Apktool

@Override
public void publish(LogRecord record) {
  if (getFormatter() == null) {
    setFormatter(new SimpleFormatter());
  }
  try {
    String message = getFormatter().format(record);
    if (record.getLevel().intValue() >= Level.WARNING.intValue()) {
      System.err.write(message.getBytes());
    } else {
      if (record.getLevel().intValue() >= Level.INFO.intValue()) {
        System.out.write(message.getBytes());
      } else {
        if (verbosity == Verbosity.VERBOSE) {
          System.out.write(message.getBytes());
        }
      }
    }
  } catch (Exception exception) {
    reportError(null, exception, ErrorManager.FORMAT_FAILURE);
  }
}
@Override

代码示例来源:origin: neo4j/neo4j

@Override
  void restore( boolean failure ) throws IOException
  {
    replace( old ).flush();
    if ( failure )
    {
      old.write( buffer.toByteArray() );
    }
  }
};

相关文章