public class TestAction {
public void TestInputSteam()throws IOException{
//InputStream is = new FileInputStream("spring-jdbc.properties");
String context = "我是一名程序员!";
//输出流
OutputStream out= new FileOutputStream("spring-jdbc.properties") ;
out.write(context.getBytes());
out.close();
System.out.println("测试成功!");
}
public void testOutputSteam()throws IOException{
InputStream is = new FileInputStream("spring-jdbc.properties");
OutputStream out = new FileOutputStream("spring-jdbc2.properties");
byte[] bytes = new byte[3];
int len =0;
while ((len=is.read(bytes))!=-1){
out.write(bytes,0,len);
}
out.close();
is.close();
}
public
static void main(String[] arg){
TestAction action = new TestAction();
try{
action.testOutputSteam();
}catch (IOException e){
e.printStackTrace();
}
}
}
}