public class FileStream { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { FileOutputStream out = new FileOutputStream("Hello.txt"); out.write("hello".getBytes()); out.close(); byte[] buf = new byte[1024]; File f = new File("Hello.txt"); FileInputStream in = new FileInputStream(f); int len = in.read(buf); System.out.println(new String(buf, 0, len)); in.close(); } catch (Exception e) { e.printStackTrace(); } }} 我只是给你举个例子!
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
FileOutputStream out = new FileOutputStream("Hello.txt");
out.write("hello".getBytes());
out.close();
byte[] buf = new byte[1024];
File f = new File("Hello.txt");
FileInputStream in = new FileInputStream(f);
int len = in.read(buf);
System.out.println(new String(buf, 0, len));
in.close();
} catch (Exception e) {
e.printStackTrace();
} }}
我只是给你举个例子!
2楼麻烦能不能举个列子不 比如说是UTF-8 格式呢 谢了!
其实都是一样的。
或 FileInputStream 不行吗?
java io部分确实很复杂...
FileReader