|
|
@@ -3,6 +3,7 @@ package com.iformall.language; |
|
|
|
import com.cybozu.labs.langdetect.Detector; |
|
|
|
import com.cybozu.labs.langdetect.DetectorFactory; |
|
|
|
import com.cybozu.labs.langdetect.LangDetectException; |
|
|
|
import com.google.common.io.ByteStreams; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.var; |
|
|
|
import org.springframework.core.io.Resource; |
|
|
@@ -28,15 +29,9 @@ public class LanguageDetect { |
|
|
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); |
|
|
|
Resource[] resources = resolver.getResources("classpath:profiles/*"); |
|
|
|
for (Resource resource:resources) { |
|
|
|
try { |
|
|
|
InputStream inputStream = resource.getInputStream(); |
|
|
|
byte[] bytes = new byte[0]; |
|
|
|
inputStream.read(bytes); |
|
|
|
profile.add(new String(bytes)); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
InputStream inputStream = resource.getInputStream(); |
|
|
|
String str = new String(ByteStreams.toByteArray(inputStream)); |
|
|
|
profile.add(str); |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|