package hanjia;
import java.io.*;
class hanjia{
public static void main(String args[]) throws IOException {
String str1 = "大学";
char cbuf[] = new char[str1.length()];
str1.getChars(0, str1.length(), cbuf, 0);
String str2 = "华软软件学院";
FileOutputStream fos = new FileOutputStream("f:/char1.txt");
OutputStreamWriter osw = new OutputStreamWriter(fos);
osw.write('广');
osw.write('州');
osw.write(cbuf);
osw.write(str2);
osw.close();
FileInputStream fis = new FileInputStream("f:/char1.txt");
InputStreamReader isr = new InputStreamReader(fis);
char mychars[] = new char[str1.length() + str2.length()];
System.out.print((char) isr.read());
System.out.print((char) isr.read());
int len = isr.read(mychars, 0, str1.length() + str2.length());
System.out.print(new String(mychars, 0, len));
isr.close();
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/3bd484f81a4cc0c6deab11736ee3bc54.png)