List of usage examples for java.util Scanner nextInt
public int nextInt()
From source file:simcommunity.TheSim.java
public static void batchSim_fixedindividui() { Scanner valore = new Scanner(System.in).useLocale(Locale.US); double o; //omogeneit System.out.print("\n==================================="); System.out.print("\nSIMULAZIONE BATCH con connessioni crescenti e numero di individui fissi\n"); System.out.print("\n==================================="); System.out.print("\n\nDimensione della comunit (fisso) "); GlobalVar.dimensionecom = valore.nextInt(); System.out.print("Numero collegamenti iniziale "); int colIniziali = valore.nextInt(); System.out.print("Numero collegamenti finale "); int colFinali = valore.nextInt(); System.out.print("Incremento collegamenti "); int incrementocollegamenti = valore.nextInt(); System.out.print("Dimensione del DNA "); GlobalVar.dimDNA = valore.nextInt(); System.out.print("Quante ere "); GlobalVar.numERE = valore.nextInt(); System.out.print("Soglia di omogeneit "); GlobalVar.omoSoglia = valore.nextDouble(); System.out.println("\nINDIVIDUI\tCONNESSIONI\tCICLI\tOMOGENEIT"); for (int i = colIniziali; i < colFinali; i = i + incrementocollegamenti) { GlobalVar.numcollegamenti = i;/*from www. j av a 2s . c om*/ o = ciclocomunita(); System.out.println( "\n" + GlobalVar.dimensionecom + "\t\t" + i + "\t\t" + GlobalVar.ereEffettuate + "\t\t" + o); } }
From source file:com.github.nethad.clustermeister.provisioning.local.AddNodesCommand.java
@Override public void execute(CommandLineArguments arguments) { logger.info("AddNodesCommand local execute."); if (isArgumentsCountFalse(arguments)) { return;//from w w w . j a va 2 s . c o m } Scanner scanner = arguments.asScanner(); int numberOfNodes = scanner.nextInt(); int numberOfCpusPerNode = scanner.nextInt(); final Configuration configuration = getNodeManager().getConfiguration(); Collection<File> artifactsToPreload = DependencyConfigurationUtil.getConfiguredDependencies(configuration); String jvmOptions = configuration.getString(ConfigurationKeys.JVM_OPTIONS_NODE, ConfigurationKeys.DEFAULT_JVM_OPTIONS_NODE); String nodeLogLevel = configuration.getString(ConfigurationKeys.LOGGING_NODE_LEVEL, ConfigurationKeys.DEFAULT_LOGGING_NODE_LEVEL); boolean nodeRemoteLogging = configuration.getBoolean(ConfigurationKeys.LOGGING_NODE_REMOTE, ConfigurationKeys.DEFAULT_LOGGING_NODE_REMOTE); int nodeRemoteLoggingPort = configuration.getInt(ConfigurationKeys.LOGGING_NODE_REMOTE_PORT, ConfigurationKeys.DEFAULT_LOGGING_NODE_REMOTE_PORT); final LocalNodeConfiguration nodeConfiguration = LocalNodeConfiguration.configurationFor(artifactsToPreload, jvmOptions, nodeLogLevel, nodeRemoteLogging, nodeRemoteLoggingPort, numberOfCpusPerNode); for (int i = 0; i < numberOfNodes; i++) { getNodeManager().addNode(nodeConfiguration); } }
From source file:ir.ac.ut.snl.mrcd.InputConverter.java
public void convert(String filename) throws FileNotFoundException, UnsupportedEncodingException { int paddingSize = 49; // 50-1; 1 baraye '\n' File file = new File(filename); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); Scanner scanner = new Scanner(bufferedReader); PrintWriter printWriter = new PrintWriter(filename + "-converted", "UTF-8"); int n = scanner.nextInt(); scanner.nextLine();/* w ww .j av a 2 s. c o m*/ printWriter.write(StringUtils.leftPad(String.valueOf(n), paddingSize)); printWriter.write('\n'); while (scanner.hasNextLine()) { String line = scanner.nextLine(); printWriter.write(StringUtils.leftPad(line, paddingSize)); printWriter.write('\n'); } scanner.close(); printWriter.close(); }
From source file:core.MusicStreaming.java
public void play() throws JavaLayerException, IOException { ftpClient = new FTPClient(); ftpClient.connect(server, port);/*ww w . j a v a 2 s .c o m*/ ftpClient.login(user, pass); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); System.out.println(ftpClient.getListHiddenFiles()); engine = ftpClient.initiateListParsing(); files = engine.getFiles(); for (int i = 0; i < files.length; i++) { System.out.println(i + " " + files[i].getName()); } Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int i = scanner.nextInt(); song = "/" + files[i].getName(); System.out.println("curently playing " + i); // song = "/Bondhu Tomar Chokher Majhe.mp3"; if (!isFirst) { System.out.println("trying to stop"); mp3player.close(); mp3player.getPosition(); in.close(); } new Thread(new Runnable() { @Override public void run() { try { isFirst = false; in = new BufferedInputStream(ftpClient.retrieveFileStream(song)); mp3player = new Player(in); mp3player.play(); } catch (Exception ex) { Logger.getLogger(MusicStreaming.class.getName()).log(Level.SEVERE, null, ex); } } }).start(); } }
From source file:com.farmerbb.secondscreen.util.U.java
public static String generateBlurb(Activity a, String key, String value, boolean isNotification) { String blurb = " "; if (a instanceof TaskerQuickActionsActivity) { blurb = a.getResources().getStringArray(R.array.pref_notification_action_list)[1]; // If this blurb is being generated for the notification, and the value is "Toggle", // set value to the actual "On" or "Off" state if (isNotification && value.equals("Toggle")) { SharedPreferences prefCurrent = getPrefCurrent(a); switch (key) { case "temp_backlight_off": if (prefCurrent.getBoolean("backlight_off", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; break; case "temp_chrome": if (prefCurrent.getBoolean("chrome", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; case "temp_immersive": case "temp_immersive_new": if (key.equals("temp_immersive_new")) key = "temp_immersive"; switch (prefCurrent.getString("immersive_new", "fallback")) { case "immersive-mode": value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; break; default: value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; }// w w w. j a v a 2 s.c o m break; case "temp_overscan": if (prefCurrent.getBoolean("overscan", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; case "temp_vibration_off": if (prefCurrent.getBoolean("vibration_off", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; break; case "temp_freeform": if (prefCurrent.getBoolean("freeform", false)) value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; break; case "temp_hdmi_rotation": switch (prefCurrent.getString("hdmi_rotation", "landscape")) { case "portrait": value = a.getResources().getStringArray(R.array.pref_hdmi_rotation_list)[1]; break; case "landscape": value = a.getResources().getStringArray(R.array.pref_hdmi_rotation_list)[0]; break; } break; } } // Modifications for non-English locales if (value.equals(a.getResources().getStringArray(R.array.pref_quick_actions_values)[0])) value = a.getResources().getStringArray(R.array.pref_quick_actions)[0]; else if (value.equals(a.getResources().getStringArray(R.array.pref_quick_actions_values)[1])) { if (key.equals("temp_overscan")) value = a.getResources().getStringArray(R.array.pref_quick_actions_overscan)[0]; else value = a.getResources().getStringArray(R.array.pref_quick_actions)[1]; } } switch (key) { case "turn_off": blurb = a.getResources().getString(R.string.quick_turn_off); break; case "lock_device": blurb = a.getResources().getStringArray(R.array.pref_notification_action_list)[2]; break; case "temp_backlight_off": blurb = a.getResources().getString(R.string.quick_backlight) + " " + value; break; case "temp_chrome": blurb = a.getResources().getString(R.string.quick_chrome) + " " + value; break; case "temp_immersive": blurb = a.getResources().getString(R.string.quick_immersive) + " " + value; break; case "temp_immersive_new": switch (value) { case "do-nothing": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[0]; break; case "status-only": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[1]; break; case "immersive-mode": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[2]; break; case "Toggle": blurb = a.getResources().getStringArray(R.array.pref_immersive_list_alt)[3]; break; } break; case "density": case "temp_density": switch (value) { case "reset": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[0]; break; case "120": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[1]; break; case "160": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[2]; break; case "213": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[3]; break; case "240": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[4]; break; case "320": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[6]; break; case "480": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[8]; break; case "640": blurb = a.getResources().getStringArray(R.array.pref_dpi_list)[10]; break; default: blurb = value + a.getResources().getString(R.string.dpi); break; } break; case "temp_overscan": blurb = a.getResources().getString(R.string.quick_overscan) + " " + value; break; case "size": case "temp_size": SharedPreferences prefMain = getPrefMain(a); if (value.equals("reset")) blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[0]; else if (prefMain.getBoolean("landscape", false)) { switch (value) { case "1920x1080": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[1]; break; case "1280x720": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[2]; break; case "854x480": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[3]; break; default: blurb = value; break; } } else { switch (value) { case "1080x1920": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[1]; break; case "720x1280": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[2]; break; case "480x854": blurb = a.getResources().getStringArray(R.array.pref_resolution_list)[3]; break; default: Scanner scanner = new Scanner(value); scanner.useDelimiter("x"); int height = scanner.nextInt(); int width = scanner.nextInt(); scanner.close(); blurb = Integer.toString(width) + "x" + Integer.toString(height); break; } } break; case "temp_rotation_lock_new": switch (value) { case "do-nothing": blurb = a.getResources().getStringArray(R.array.pref_rotation_list)[0]; break; case "auto-rotate": blurb = a.getResources().getStringArray(R.array.pref_rotation_list)[1]; break; case "landscape": blurb = a.getResources().getStringArray(R.array.pref_rotation_list)[2]; break; } break; case "temp_vibration_off": blurb = a.getResources().getString(R.string.quick_vibration) + " " + value; break; case "temp_freeform": blurb = a.getResources().getString(R.string.quick_freeform) + " " + value; break; case "temp_hdmi_rotation": blurb = a.getResources().getString(R.string.quick_hdmi_rotation) + " " + value; break; } return blurb; }
From source file:br.edu.ifes.bd2hibernate.cgt.Menu.java
private int lerInt() { System.out.println(this.messages.get("ID")); Scanner sc = new Scanner(System.in); int id = sc.nextInt(); return id;/*from www .j a va 2 s . c o m*/ }
From source file:org.sipfoundry.sipxconfig.conference.FreeswitchApiResultParserImpl.java
private ActiveConferenceMember parseConferenceMember(String line, String conferenceName) { ActiveConferenceMember member = new ActiveConferenceMember(); Scanner scan = new Scanner(line); scan.useDelimiter(COMMAND_LIST_DELIM); member.setId(scan.nextInt()); String sipAddress = scan.next().split("/")[2]; member.setUuid(scan.next());/*from w w w. j ava 2 s. c o m*/ String callerIdName = scan.next(); if (callerIdName.equals(conferenceName)) { callerIdName = ""; } scan.next(); // skip caller ID number String permissions = scan.next(); member.setCanHear(permissions.contains("hear")); member.setCanSpeak(permissions.contains("speak")); member.setName(callerIdName + " (" + sipAddress + ")"); member.setVolumeIn(scan.nextInt()); member.setVolumeOut(scan.nextInt()); member.setEnergyLevel(scan.nextInt()); return member; }
From source file:org.sipfoundry.sipxconfig.freeswitch.api.FreeswitchApiResultParserImpl.java
private ActiveConferenceMember parseConferenceMember(String line, String conferenceName) { ActiveConferenceMember member = new ActiveConferenceMember(); Scanner scan = new Scanner(line); scan.useDelimiter(COMMAND_LIST_DELIM); member.setId(scan.nextInt()); String sipAddress = scan.next().split("/")[2]; member.setUuid(scan.next());//from w ww . j a va 2s.c om String callerIdName = scan.next(); if (callerIdName.equals(conferenceName)) { callerIdName = ""; } String number = scan.next(); String permissions = scan.next(); member.setCanHear(permissions.contains("hear")); member.setCanSpeak(permissions.contains("speak")); member.setNumber(number); member.setName(callerIdName + " (" + sipAddress + ")"); member.setVolumeIn(scan.nextInt()); member.setVolumeOut(scan.nextInt()); member.setEnergyLevel(scan.nextInt()); return member; }
From source file:de.bley.word.menu.Menue.java
/** * Die Oberflaeche startet in der Console. *///from ww w .j a v a 2 s. c om @Override public void showMenue() { zuordnung = PropertieManager.getInstance().getZuordnung(); boolean run = true; final Scanner scan = new Scanner(System.in); while (run) { try { showFiles(scan); zuordnung.getEingabe().readFile(); final int input = scan.nextInt(); switch (input) { case 0: readFile(); break; case 1: writeFrile(scan); break; default: run = false; break; } } catch (Exception e) { run = false; } } }
From source file:org.colombbus.tangara.core.Version.java
private void doExtractFieldsFromText(String textVersion) throws Exception { Scanner scanner = new Scanner(textVersion); scanner.useDelimiter("\\."); //$NON-NLS-1$ major = scanner.nextInt(); if (scanner.hasNext()) minor = scanner.nextInt();/*from w w w . j a v a 2 s .c o m*/ if (scanner.hasNext()) fix = scanner.nextInt(); if (scanner.hasNext()) qualifier = scanner.next(); if (scanner.hasNext()) { throw new Exception("Too many fields"); //$NON-NLS-1$ } scanner.close(); }