[공유] RFC 중국어 문서
3838 단어 rfc
package canghailan.downloader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
import java.net.URLConnection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RFCDownload {
private static final String DOWNLOAD_DIR = "D:\\rfc_cn";
private static final String[] URLS = {
"http://www.cnpaf.net/Class/RFC/200411/1047.html",
"http://www.cnpaf.net/Class/RFC/200411/1048.html",
"http://www.cnpaf.net/Class/RFC/200411/1049.html",
"http://www.cnpaf.net/Class/RFC/200411/1050.html",
"http://www.cnpaf.net/Class/RFC/200411/1051.html",
"http://www.cnpaf.net/Class/RFC/200411/1052.html",
"http://www.cnpaf.net/Class/RFC/200411/1053.html",
"http://www.cnpaf.net/Class/RFC/200411/1054.html" };
private static final String DEFAULT_CHARSET = "gbk";
private static final Pattern A_PATTERN = Pattern
.compile("<[Aa][^>]+href=['\"]?([^\\s'\"]*)['\"]?[^>]*>([^<]*)</\\s*[Aa]\\s*>");
public static String loadURL(String url) throws IOException {
Reader reader = null;
try {
URLConnection conn = new URL(url).openConnection();
conn.connect();
int length = conn.getContentLength();
String charset = conn.getContentEncoding();
reader = new BufferedReader(new InputStreamReader(
conn.getInputStream(), charset == null ? DEFAULT_CHARSET
: charset));
StringBuilder buffer = new StringBuilder(length);
for (;;) {
int ch = reader.read();
if (ch == -1) {
break;
}
buffer.append((char) ch);
}
return buffer.toString();
} finally {
if (reader != null) {
reader.close();
}
}
}
public static void saveFile(String file, String content) throws IOException {
Writer writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file), "utf-8"));
writer.write(content);
writer.flush();
} finally {
if (writer != null) {
writer.close();
}
}
}
public static void loadAndSave(String url, String text) throws IOException {
saveFile(getFile(text), loadURL(url));
}
public static String getFile(String text) {
return DOWNLOAD_DIR + File.separator
+ text.replace("RFC", "rfc").replace("/", "-") + ".txt";
}
public static void main(String[] args) throws IOException {
for (String pageURL : URLS) {
String page = loadURL(pageURL);
Matcher matcher = A_PATTERN.matcher(page);
while (matcher.find()) {
String url = matcher.group(1);
String text = matcher.group(2);
if (url.contains("/rfc/")) {
System.out.println(url + "(" + text + ")");
loadAndSave(url, text);
}
}
}
}
}
package canghailan.downloader;
import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.Pattern;
public class RFCRename {
private static final String DIR = "D:\\rfc_cn";
private static final Pattern BAD_FILE = Pattern.compile("rfc\\d+_.*");
public static void main(String[] args) {
File dir = new File(DIR);
for (String badFile : dir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return BAD_FILE.matcher(name).matches();
}
})) {
String name = badFile.replaceFirst("_", " ");
new File(dir, badFile).renameTo(new File(dir, name));
}
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
SAP RFC from JSP via JCO이 article shows a simple JSP program calling SAP Remote function module via JCo (SAP Java Connector). How to create JCO ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.