public static void main(String[] args) throws Exception { // String f="d:"+File.separator+"data"+File.separator+"fword.txt"; String f="d:"+File.separator+"data"; File m=new File(f); String[] s=m.list(new FilenameFilter(){ public boolean accept(File dir, String name) {...
本次复习的是I/O(输入/出)(总体的复习) InputStream输入流/OutputStream输出流 Node Stream节点流 /Processing Stream处理流 Character Stream 字符流/Byte Stream字节流按照数据流动的方法:有输入流和输出流 输入流只能读取数据,不能写出数据 输出流只能写出数据,不能读入数据 除了RandomAccessFile类(即可读也可写)按照数据流所关联的...
import java.io.File;import java.io.IOException;import java.io.RandomAccessFile;public class TestRandomAccessFile{ private File file; public static void main(String[] args){ TestRandomAccessFile traf = new TestRandomAccessFile(); traf.init(); traf.record("Billy",22); ...
import java.io.*;import java.util.Date;public class TestSetOutput{ public static void main(String[] args){ PrintStream ps = null; PrintStream ps_error = null; try{ ps = new PrintStream(new FileOutputStream("output.txt",true)); System.setOut(ps);//设置...
import java.io.*;public class TestSetInput{ public static void main(String[] args){ try{ //FileInputStream fis = new FileInputStream("source.txt"); //System.setIn(fis); 如果取消了这里的,将在下面的System.io是文件中的内容 int avg = 0; int total = 0; ...
import java.io.*;public class TestCharArrayReader{ public static void main(String[] args){ char[] b = {'I',' ','a','m',' ','S','a','i','l','i','n','g','!'}; CharArrayReader car = new CharArrayReader(b); MyReader mr = new MyReader(); mr.getInfo(car); } }~...
import java.io.*;public class Test{ public static void main(String args[]){ try{ FileOutputStream fos; DataOutputStream dos; FileInputStream fis; DataInputStream dis; fos = new FileOutputStream("myfile.data"); dos = new...
import java.io.*;
public class TestWriteFile{ public static void main (String[] args) { File file = new File("tt.txt"); try { InputStreamReader is = new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); PrintWriter out = new PrintWriter(new FileWriter(file)); St...
import java.io.InputStreamReader;import java.io.BufferedReader;import java.io.IOException;public class TestStandardInput{ public static void main (String args[]) { String s; InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(...
import java.io.*;public class Test { public static void main(String[] args) { try { FileReader input = new FileReader("Test.java"); BufferedReader br = new BufferedReader(input); FileWriter output = new FileWriter("temp.txt"); BufferedWriter...
import java.io.*;public class Test { public static void main(String[] args) { try { FileReader input = new FileReader("a.txt"); FileWriter output = new FileWriter("temp.txt"); int read = input.read(); while ( read != -1 ) { ...
import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;public class CopyFile{ public static void main(String[] args) { try { FileInputStream fis = new FileInputStream ("a.jpg");//本地中存在的文件 FileOutputStream fos = new FileOutputStrea...
标准的输入格式InputStreamReader isr=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(isr);
从Socket中得到的标准输出格式
PrintWriter pw=new PrintWriter(s.getOutputStream());//s为Socket对象名
从Socket中得到的标准输入格式
BufferedReader bw=new BufferedReader(new InputStreamReader(s.getInputStream()));
...