package ioput;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class aaa {
/*public static void main(String[] args) {
args = new String[]{"a","b","c"};
for (int i = 0; i < args.length; i++) {
System.out.println("args[" + i + "] is <" + args[i] + ">");
}
}*/
/*public static void main(String args[]) {
int b;
try {
System.out.println("please Input:");
while ((b = System.in.read()) != -1) {
System.out.print((char) b);
}
} catch (IOException e) {
System.out.println(e.toString());
}
} */
/* public static void main(String args[]) {
String s;
// 创建缓冲区阅读器从键盘逐行读入数据
InputStreamReader ir = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(ir);
System.out.println("Unix系统: ctrl-d 或 ctrl-c 退出"
+ "
Windows系统: ctrl-z 退出");
try {
// 读一行数据,并标准输出至显示器
s = in.readLine();
// readLine()方法运行时若发生I/O错误,将抛出IOException异常
while (s != null) {
System.out.println("Read: " + s);
s = in.readLine();
}
// 关闭缓冲阅读器
in.close();
} catch (IOException e) { // Catch any IO exceptions.
e.printStackTrace();
}
}*/
//从磁盘读数据
/*public static void main(String[] args){
try {
File file = new File("d:/aaa/gbk.txt");
InputStream fileStream = new FileInputStream(file);
InputStreamReader read = new InputStreamReader(fileStream,"utf-8");
BufferedReader bufferedReader = new BufferedReader(read);
String text = null;
while((text =bufferedReader.readLine())!=null){
System.out.println(text);
}
read.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}*/
//数据写入磁盘
public static void main(String[] args){
String path = "d:/tr/rt";
File f = new File(path);
if(!f.exists()){
f.mkdirs();
}
String fileName="test.txt";
File file = new File(f,fileName);
if(!file.exists()){
try {
file.createNewFile();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
String s = "1234567890";
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write(s);
writer.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}