摘要:
import java.io.*;public class Serialization { public static void main(String [] args) { Student stu1 = new Student(1, "Ronnie", 37, "snooker"); Student stu2 = new Student(2, "John", 37, "snooker"); try { ObjectOutputStream os = new ObjectOutputStream(new FileO 阅读全文
摘要:
import java.io.*;public class DataStreamTest { public static void main(String [] args) { try { FileOutputStream fos = new FileOutputStream("count.txt"); BufferedOutputStream bos = new BufferedOutputStream(fos); DataOutputStream dos = new DataOutputStream(bos); dos.writeUTF("ab中国" 阅读全文
摘要:
72、EJB的角色和三个对象 一个完整的基于EJB的分布式计算结构由六个角色组成,这六个角色可以由不同的开发商提供,每个角色所作的工作必须遵循Sun公司提供的EJB规范,以保证彼此之间的兼容性。这六个角色分别是EJB组件开发者(Enterprise Bean Provider) 、应用组合者(Application Assembler)、部署者(Deployer)、EJB 服务器提供者(EJB Server Provider)、EJB 容器提供者(EJB Container Provider)、系统管理员(System Administrator)三个对象是Remote(Local)接口、Ho 阅读全文
摘要:
ByteArrayInputStream和ByteArrayOutputStream,用于以IO流的方式来完成对字节数组内容的读写,来支持类似内存虚拟文件或者内存映射文件的功能实例:import java.io.*;public class ByteArrayStreamTest { public static void main(String [] args) { String str = "abcdef"; ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes()); ByteArrayOutpu 阅读全文
摘要:
PipedOutputStream和PipedInputStream用于在应用程序中创建管道通信实例:import java.io.*;public class PipedStreamTest { public static void main(String [] args) { Sender sender = new Sender(); Receiver receiver = new Receiver(); PipedOutputStream outStream = sender.getOutStream(); PipedInputStream inStream = receiv... 阅读全文
摘要:
Reader和Writer是所有字符流类的抽象基类,用于简化对字符串的输入输出编程,即用于读写文本数据实例:import java.io.*;public class FileReaderWriterTest { public static void main(String [] args) { try { FileWriter writer = new FileWriter("hello.txt"); writer.write("love_snooker"); writer.close(); FileReader reader = new FileRe 阅读全文
摘要:
I/O类包括节点流类和包装流类FileOutputStream和FileInputStream创建磁盘文件的输入输出流对象创建FileInputStream实例对象时,指定的文件应当是存在和可读的,创建FileOutputStream实例对象时,如果指定的文件已经存在,这个文件中的原来内容将被清除创建FileOutputStream实例对象时,可以指定还不存在的文件名,不能指定一个已被其他程序打开的文件实例:import java.io.*;public class FileStreamTest { public static void main(String [] args) { try . 阅读全文