private static void setScanner(Scanner scanner) { StdIn.scanner = scanner; StdIn.scanner.useLocale(LOCALE); }
private void initScanner() { scanner.useLocale(Locale.US); scanner.useDelimiter("[ ,\\r\\n]"); }
/** * Initializes an input stream from standard input. */ public In() { scanner = new Scanner(new BufferedInputStream(System.in), CHARSET_NAME); scanner.useLocale(LOCALE); }
Scanner scan = new Scanner(System.in); scan.useLocale(Locale.US);
/** * Initializes an input stream from a socket. * * @param socket the socket * @throws IllegalArgumentException if cannot open {@code socket} * @throws IllegalArgumentException if {@code socket} is {@code null} */ public In(Socket socket) { if (socket == null) throw new IllegalArgumentException("socket argument is null"); try { InputStream is = socket.getInputStream(); scanner = new Scanner(new BufferedInputStream(is), CHARSET_NAME); scanner.useLocale(LOCALE); } catch (IOException ioe) { throw new IllegalArgumentException("Could not open " + socket, ioe); } }
/** * Initializes an input stream from a URL. * * @param url the URL * @throws IllegalArgumentException if cannot open {@code url} * @throws IllegalArgumentException if {@code url} is {@code null} */ public In(URL url) { if (url == null) throw new IllegalArgumentException("url argument is null"); try { URLConnection site = url.openConnection(); InputStream is = site.getInputStream(); scanner = new Scanner(new BufferedInputStream(is), CHARSET_NAME); scanner.useLocale(LOCALE); } catch (IOException ioe) { throw new IllegalArgumentException("Could not open " + url, ioe); } }
/** * Initializes an input stream from a file. * * @param file the file * @throws IllegalArgumentException if cannot open {@code file} * @throws IllegalArgumentException if {@code file} is {@code null} */ public In(File file) { if (file == null) throw new IllegalArgumentException("file argument is null"); try { // for consistency with StdIn, wrap with BufferedInputStream instead of use // file as argument to Scanner FileInputStream fis = new FileInputStream(file); scanner = new Scanner(new BufferedInputStream(fis), CHARSET_NAME); scanner.useLocale(LOCALE); } catch (IOException ioe) { throw new IllegalArgumentException("Could not open " + file, ioe); } }
public static List<ProcessInformations> buildProcessInformations(InputStream in, boolean windows, boolean macOrAix) { final String charset; if (windows) { charset = "Cp1252"; } else { charset = "UTF-8"; } final Scanner sc = new Scanner(in, charset); sc.useRadix(10); sc.useLocale(Locale.US); sc.nextLine(); if (windows) { sc.nextLine(); sc.nextLine(); } final List<ProcessInformations> processInfos = new ArrayList<ProcessInformations>(); while (sc.hasNext()) { final ProcessInformations processInfo = new ProcessInformations(sc, windows, macOrAix); processInfos.add(processInfo); } return Collections.unmodifiableList(processInfos); }
try { s = new Scanner(new BufferedReader(new InputStreamReader(mixFiltersStream, "UTF-8"))); s.useLocale(Locale.US);
try { s = new Scanner(new BufferedReader(new InputStreamReader(mixFiltersStream, "UTF-8"))); s.useLocale(Locale.US);
try { Scanner scan = new Scanner(in, "UTF-8"); scan.useLocale(Locale.US); // Fix commas / periods ?? while (scan.hasNext()){ String cmd = scan.next();
@Signature(@Arg(value = "locale", nativeType = WrapLocale.class)) public Memory useLocale(Environment env, Memory... args) { scanner.useLocale(args[0].toObject(WrapLocale.class).getLocale()); return new ObjectMemory(this); }
scan.useLocale(Locale.US);
in = info.openStream(); scan = new Scanner(in); scan.useLocale(Locale.US);
scanner.useLocale(locale); switch (nonNillOutput.getType()) { case LONG:
Scanner scanner = new Scanner(System.in).useLocale(Locale.US);
Scanner in = new Scanner(System.in); in.useLocale(Locale.ENGLISH); while (in.hasNextDouble()) { System.out.println(Double.parseDouble(in.nextLine())); }
String doubles = "1.25, 1.65, 1.47"; Scanner f = new Scanner(doubles); f.useLocale(Locale.US); //without this line the program wouldn't work //on machines with different locales f.useDelimiter(",\\s*"); while (f.hasNextDouble()) { System.out.println(f.nextDouble()); }
package test; import java.util.Locale; import java.util.Scanner; public class TryDouble { public static void main(String [] args){ Scanner jin = new Scanner(System.in).useLocale(Locale.US); double a = jin.nextDouble(); double b = jin.nextDouble(); double c = jin.nextDouble(); System.out.println(a + b + c); } }