Search in sources :

Example 41 with Scanner

use of java.util.Scanner in project languagetool by languagetool-org.

the class PortugueseAccentuationDataLoader method loadWords.

Map<String, AnalyzedTokenReadings> loadWords(String path) {
    final Map<String, AnalyzedTokenReadings> map = new HashMap<>();
    final InputStream inputStream = JLanguageTool.getDataBroker().getFromRulesDirAsStream(path);
    try (Scanner scanner = new Scanner(inputStream, FILE_ENCODING)) {
        while (scanner.hasNextLine()) {
            final String line = scanner.nextLine().trim();
            if (line.isEmpty() || line.charAt(0) == '#') {
                // ignore comments
                continue;
            }
            final String[] parts = line.split(";");
            if (parts.length != 3) {
                throw new RuntimeException("Format error in file " + path + ", line: " + line + ", " + "expected 3 semicolon-separated parts, got " + parts.length);
            }
            final AnalyzedToken analyzedToken = new AnalyzedToken(parts[1], parts[2], null);
            map.put(parts[0], new AnalyzedTokenReadings(analyzedToken, 0));
        }
    }
    return map;
}
Also used : Scanner(java.util.Scanner) AnalyzedToken(org.languagetool.AnalyzedToken) HashMap(java.util.HashMap) InputStream(java.io.InputStream) AnalyzedTokenReadings(org.languagetool.AnalyzedTokenReadings)

Example 42 with Scanner

use of java.util.Scanner in project realm-java by realm.

the class ComputerIdentifierGenerator method getWindowsIdentifier.

private static String getWindowsIdentifier() throws IOException, NoSuchAlgorithmException {
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec(new String[] { "wmic", "csproduct", "get", "UUID" });
    String result = null;
    InputStream is = process.getInputStream();
    Scanner sc = new Scanner(process.getInputStream());
    try {
        while (sc.hasNext()) {
            String next = sc.next();
            if (next.contains("UUID")) {
                result = sc.next().trim();
                break;
            }
        }
    } finally {
        is.close();
    }
    return result == null ? UNKNOWN : Utils.hexStringify(Utils.sha256Hash(result.getBytes()));
}
Also used : Scanner(java.util.Scanner) InputStream(java.io.InputStream)

Example 43 with Scanner

use of java.util.Scanner in project zoj by licheng.

the class Main method main.

public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    try {
        for (; ; ) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a + b);
        }
    } catch (NoSuchElementException e) {
    }
    out.close();
}
Also used : Scanner(java.util.Scanner) NoSuchElementException(java.util.NoSuchElementException) PrintWriter(java.io.PrintWriter)

Example 44 with Scanner

use of java.util.Scanner in project zoj by licheng.

the class Main method main.

public static void main() {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    try {
        for (; ; ) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a + b);
        }
    } catch (NoSuchElementException e) {
    }
    out.close();
}
Also used : Scanner(java.util.Scanner) NoSuchElementException(java.util.NoSuchElementException) PrintWriter(java.io.PrintWriter)

Example 45 with Scanner

use of java.util.Scanner in project HanLP by hankcs.

the class PlayGround method main.

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String line;
    while ((line = scanner.nextLine()).length() > 0) {
        seg(line);
    }
}
Also used : Scanner(java.util.Scanner)

Aggregations

Scanner (java.util.Scanner)862 File (java.io.File)135 ArrayList (java.util.ArrayList)77 IOException (java.io.IOException)72 Test (org.junit.Test)70 NoSuchElementException (java.util.NoSuchElementException)59 InputStream (java.io.InputStream)54 ServiceBuilder (com.github.scribejava.core.builder.ServiceBuilder)49 OAuthRequest (com.github.scribejava.core.model.OAuthRequest)49 Response (com.github.scribejava.core.model.Response)49 FileNotFoundException (java.io.FileNotFoundException)47 InputMismatchException (java.util.InputMismatchException)47 HashMap (java.util.HashMap)35 FileInputStream (java.io.FileInputStream)33 OAuth20Service (com.github.scribejava.core.oauth.OAuth20Service)31 OAuth2AccessToken (com.github.scribejava.core.model.OAuth2AccessToken)29 Locale (java.util.Locale)24 BigInteger (java.math.BigInteger)23 List (java.util.List)22 OAuth1AccessToken (com.github.scribejava.core.model.OAuth1AccessToken)18