Java类型的字符转换方法是什么?不用急,下面一起和小编来学习学习吧!
利用字节流FileOutputStream写文文本文件
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
OutputStream obj = FileOutputStream("文件名称");
String array ="字符串";
String [] aa = array.getBytes();
obj.write(aa,0,aa.length());
obj.close();
利用字符流BufferedReader读文本文件
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
FileReader fr = new FileReader("文件名称");
BufferedReader br = new BufferedReader(fr);
br.readLine();
br.close();
fr.close();
利用BufferedWriter写文本文件
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
FileWriter fw = new FileWriter("文件名称");
BufferedWriter bw = new BufferedWriter(fw);
bw.writer("字符串");
bw.flush();
fw.close();
利用字节流DateInputStream读二进制文件
import java.io.FileInputStream;
import java.io.DateInputStream;
FileInputStream fis = new FileInputStream("文件名称");
DateInputStream dis = new DateInputStreamI(fis);
dis.readInt();
dis.readByte();
dis.close();
利用字节流DateOutputStream写二进制文件
import java.io.FileOutputStream;
import java.io.DateOutputStream;
FileOutputStream fop = new FileOutputStream("文件名称");
DateOutputStream dop = new DateOutputStream(fop);
dop.write(1);
dop.close();
JDBC 应用程序的结构
import java.sql.SQLException;
import java.sql.Conncetion;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException e){
System.out.println(e);
}
try{
String aa = "jdbc:odbc:test";
Connection con = DriverManager.getConnection(aa);
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("查询语句");
while(rs.next())
rs.close()
s.close();
con.close();
} catch(SQLException ee){
System.out.print(ee);
}