读书人

JAVA IO有关问题

发布时间: 2012-01-29 21:39:32 作者: rapoo

JAVA IO问题
读取A.tex内容删除第一个字符然后写到B.txe 在删除A.txe
能实现么?希望能给个代码!!!谢谢

[解决办法]

Java code
public static void main(String[] args) {        File fa = new File("a.txt");        File fb = new File("b.txt");                try {                        if(!fb.exists()){                fb.createNewFile();            }                        ObjectInputStream ois = new ObjectInputStream (new FileInputStream(fa));            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fb));                        char c = ois.readChar();            oos.writeChar(c);                        oos.close();            ois.close();                        fa.delete();                    } catch (FileNotFoundException e) {            e.printStackTrace();        } catch (IOException e) {            e.printStackTrace();        }    }
[解决办法]
探讨

Java code

public static void main(String[] args) {
File fa = new File("a.txt");
File fb = new File("b.txt");

try {

if(!fb.exists()){
……

读书人网 >J2SE开发

热点推荐