この問題を解決する方法を見つけました。ここにはコードFYIがあります:
public static String getFileType(String filePath){
String fileType ="";
int count=0;
FileInputStream in=null;
try{
in =new FileInputStream(filePath);
StringBuffer systemFormat = new StringBuffer();
int i = 0;
while((count=in.read())!=-1){
//CR: ASCII: 13
if(count == 13){
systemFormat.append(String.valueOf(count));
i++;
}
//LF: ASCII: 10
if(count == 10){
systemFormat.append(String.valueOf(count));
i++;
}
if(i == 2) break;
}
if(systemFormat.toString().contains("1313")){
fileType = "Mac";
System.out.println("It's a Mac format file");
}else if(systemFormat.toString().contains("1310")){
fileType = "Windows";
System.out.println("It's a Windows format file");
}else if(systemFormat.toString().contains("1010")){
fileType = "Unix";
System.out.println("It's a Unix format file");
}
}catch(FileNotFoundException e) {
util.LogWriter.log(e);
}catch(IOException e) {
util.LogWriter.log(e);
}
return fileType;
}
私はあなたがどのフォーマットであるか知る必要はないとは思わないでしょう。私が間違っていないと、SQL \ * Loaderはうまく両方のフォーマットを受け入れます。 –
[JAVA](http://stackoverflow.com/questions/207947/how-do-i-get-a-platform-dependent-new-line-character)を使用してテキストファイルの形式を取得するには、このリンクを参照してください。 – Karthik
@a_horse_with_no_name UnixシステムにあるSQL \ * LoaderでWindows形式のファイルをロードするときに問題が発生しました。 SQL \ * Loaderはソースファイルを誤って解析します。だから私はファイルの形式を直接javaを使用して取得し、SQL \ *ローダーのctlファイルで定義します。それから、SQL \ * Loaderが正しく処理します。 –