📄 example7_3.java
字号:
/*
* Example7_3.java
*
* Created on 2006年9月15日, 下午5:01
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package example7_3;
import java.io.*;
/**
*
* @author Administrator
*/
public class Example7_3 {
/** Creates a new instance of Example7_3 */
public Example7_3() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException{
// TODO code application logic here
ByteArrayOutputStream f = new ByteArrayOutputStream();
String s = "This should end up in the array";
byte buf[] = s.getBytes();
f.write(buf);
System.out.println("Buffer as a string");
System.out.println(f.toString());
System.out.println("Into array");
byte b[] = f.toByteArray();
for (int i=0;i<b.length;i++)
System.out.print((char)b[i]);
System.out.println("\nTo an OutputStream()");
OutputStream f2 = new FileOutputStream("test.txt");
f.writeTo(f2);f2.close();
System.out.println("Doing a reset");
f.reset();
for (int i=0; i<3; i++)
f.write('X');
System.out.println(f.toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -