000000000065535f000000001600000n000000014400000n000006581200000n类似这样。packageM;importjava.io.BufferedReader;importjava.io.FileInputStream;importjava.io.FileOutputStre...
0000000000 65535 f
0000000016 00000 n
0000000144 00000 n
0000065812 00000 n
类似这样。
package M;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.sql.*;
public class ME {
public static void main(String[] args) throws IOException {
BufferedReader fis = new BufferedReader(new FileReader("c://rf//x.pdf"));
FileInputStream fis2 = new FileInputStream("c://rf//x.pdf");
FileOutputStream fos = new FileOutputStream("c://5.txt");
String ii = "";
String x = "";
String line = "";
while ((line = fis.readLine()) != null) { // 截取startxref后面的数字,即交叉引用表的开始位置
ii = ii + line;
}
line = ii;
if (line.lastIndexOf("startxref") != -1) {
int index = line.lastIndexOf("startxref");
line = line.substring(index + 9);
index = line.lastIndexOf("%%EOF");
line = line.substring(0, index);
}
while ((x = fis.readLine()) != null) { // 截取Size后面的数字,即整个交叉引用表的对象数目
ii = ii + x + "\r\n";
}
x = ii;
if (x.lastIndexOf("Size ") != -1) {
int index = x.lastIndexOf("Size ");
x = x.substring(index + 5);
index = x.lastIndexOf("/Root ");
x = x.substring(0, index);
}
else {
}
byte[] buf = new byte[1024 * 400];
fis2.read(buf);
fos.write(buf, Integer.parseInt(line), Integer.parseInt(x)*20+10);//把字符串转换成整型
String str2 = new String(buf, Integer.parseInt(line), Integer.parseInt(x)*20+10);//打印截取内容
String [] s1= str2.split("\\D+");//拆分str2字符串
for(int i=0;i
System.out.println(s1[i]);
System.out.println(str2.split("\\D+")[0]);//0
System.out.println(str2.split("\\D+")[1]);//32
System.out.println(str2.split("\\D+")[2]);
System.out.println(str2.split("\\D+")[3]);//数据库中的第一行中第一个数
System.out.println(str2.split("\\D+")[4]);//数据库中的第一行中第二个数
System.out.println(str2.split("\\D+")[5]);//数据库中的第二行中第一个数
System.out.println(str2.split("\\D+")[6]);//数据库中的第二行中第二个数
//以此类推
fos.close();
fis.close();
fis2.close();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:driver={Microsoft Access Driver(*.mdb)};DBQ=C://rf//fen.mdb";
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sql1="insert into table6(Beginingnumber,generationnumber)VALUES('"+str2.split("\\D+")[3]+"','"+str2.split("\\D+")[4]+"')";//重点这句不会,因为拆分之后,有很多组数,不能像上面那样一个一个
statement.executeUpdate(sql1);
connection.close();
statement.close();}
catch(Exception ex){
System.out.println(ex);
System.exit(0);
}finally{
{
}
}
}
}
展开