转自:
Java OutputStream.write()的功能简介说明
下文讲述java中OutputStream.write()方法的功能简介说明,如下所示:
OutputStream.write()方法的功能:
将数据写入到输出流中
OutputStream.write()方法的语法:
public abstract void write(int b)
public void write(byte[] b)
public void write(byte[] b,int off,int len)
参数说明
b:指定的字节
off:数组b中将写入数据的初始偏移量
len:待读取的最大字节数
返回值说明
无任何返回
例
public static void main(String[] args) { OutputStream os = null; try { String str = "我是一个java学习站---JAVA265.com"; byte[] bytes = str.getBytes(); for(int i = 0; i < bytes.length; i++) { os.write(bytes[i]); } } catch(IOException e) { e.printStackTrace(); } finally { if(os != null) { try { os.close(); //关闭资源 } catch(IOException e) {} } } }