📄 a0eb95fdb70d001d131be4803f486f0b
字号:
package com.lib.biz;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.ListIterator;
import com.lib.cls.Marc;
import com.lib.persistence.hibernate.pojo.Book;
public class MarcAnalyze {
private static MarcAnalyze instance;
public static MarcAnalyze getInstance(){
if (instance==null){
instance = new MarcAnalyze();
}
return instance;
}
public Marc ReadMarc(File file) {
int slen,add,temp;
StringBuffer sb = new StringBuffer();
Marc marc = new Marc();
File f = new File(file.getPath());
try {
InputStreamReader read = new InputStreamReader(new FileInputStream(f), "ISO-8859-1");
BufferedReader reader = new BufferedReader(read);
String aa;
while((aa = reader.readLine()) != null)
{
String bb = ReplaceString.RepAsc(aa);
sb.append(bb);
slen = Integer.parseInt(sb.substring(1, 5));
add = Integer.parseInt(sb.substring(13, 17));
for(temp = 24; temp < add -1; temp += 12)
{
String c = "";
String h = "";
h = sb.substring(temp, temp + 3);
marc.head.add(h);
c = sb.substring(add + Integer.parseInt(sb.substring(temp + 7, temp + 12)), add + Integer.parseInt(sb.substring(temp + 7, temp + 12)) + Integer.parseInt(sb.substring(temp + 3, temp + 7)));
c = new String(c.getBytes("ISO-8859-1"), "gbk");
marc.content.add(c);
}
}
return marc;
} catch (Exception e) {
System.out.println("Errors");
return marc=null;
}
}
public Book MarcSort(Marc marc){
Book book = new Book();
List head = marc.getHead();
List content = marc.getContent();
String temp;
String[] arry;
for(int i=0;i<head.size();i++){
String valueH = (String)head.get(i);
if(valueH.equals("010")){
temp = (String)content.get(i);
System.out.println(temp);
arry = temp.split("f");
book.setIsbn(arry[1].substring(1));
book.setPrice(arry[2].substring(1));
System.out.println(arry[1]);
}
}
return book;
}
// public static void main(String[] args) {
// File file = new File("E:\\keji.ISO");
// Marc marc = MarcAnalyze.getInstance().ReadMarc(file);
// Book book =MarcAnalyze.getInstance().MarcSort(marc);
// System.out.println(">>"+book.getIsbn());
// System.out.println(">>"+book.getPrice());
// }
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -