📄 204b6af7e70c001d137bd969311cc581
字号:
package com.lib.biz;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.List;
import com.lib.cls.Marc;
import com.lib.persistence.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)
{
sb.append(aa);
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 content = marc.getContent();
book.setIsbn(content.get(1).toString().substring(4, 18));
book.setPrice(content.get(1).toString().substring(19,28));
System.out.println(book.getPrice());
System.out.println(book.getIsbn());
return book;
}
public static void main(String[] args) {
File file = new File("E:\\keji.ISO");
Marc marc = MarcAnalyze.getInstance().ReadMarc(file);
MarcAnalyze.getInstance().MarcSort(marc);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -