text
stringlengths
14
410k
label
int32
0
9
public synchronized void stop(){ listening=false; try { is.close(); con.close(); } catch (IOException e) { e.printStackTrace(); } System.out.println("handler stopping"); }
1
@Override public void focusLost(FocusEvent evt) { if (evt.getSource().equals(tripFormFileNameLabel)) { MainWindow.setupData.setFormFileName (tripFormFileNameLabel.getText()); } if (evt.getSource().equals(dataFileFileNameLabel)) { MainWindow.setupData.setDataFileName (dataFileFileNameLabel.getText());...
2
@Test public void testEj2_e(){ final int max = 10; final Grafo grafo = new Grafo(max); for (int i = 0; i < max; i++) grafo.agregarCiudad(CIUDADES.get(i)); final List<Vuelo> todosVuelos = new ArrayList<Vuelo>(); final Vuelo vuelo1 = new Vuelo(CIUDADES.get(1), CIUDADES.get(3), 100); final Vuelo vuelo2 = n...
7
public int getSerializedSize() { int size = memoizedSize; if (size != -1) { return size; } size = 0; final boolean isMessageSet = getDescriptorForType().getOptions().getMessageSetWireFormat(); for (final Map.Entry<FieldDescriptor, Object> entry : getAllFields().entrySet()...
7
public static void analyzePath(String path) { File name = new File(path); if(name.exists()) { System.out.println(""+name.getName()+"\n" + "exists "+(name.isFile() ? "is a file": "is not a file")+"\n" + ""+(name.isDirectory() ? "is a directory"...
6
private void readFile(InputStream in, File outFolder) throws IOException { log.trace("Reading packaged file"); int dataSize = readInt(in); String fileName = readString(in); log.trace("Filename: " + fileName + " ("+dataSize+"b)"); File outFile = new File( outFolder, fileName ); outFile.getParentFil...
3
public double doubleValue() // returns Double type value of data N,F { String s = value.trim(); return ( s.length()==0 || s.indexOf("*")>=0 ? 0 : Double.parseDouble(s) ); }
2
private void handleMouseEvent(final MouseEvent MOUSE_EVENT) { final Object SRC = MOUSE_EVENT.getSource(); final EventType TYPE = MOUSE_EVENT.getEventType(); if (SRC.equals(targetIndicator)) { if (MouseEvent.MOUSE_PRESSED == TYPE) { userAction = true; ...
4
public Object process(Cache highLevelCache) { if (isHighLevelCacheEnable()) { try { Object result = doInCache(highLevelCache); setHighLevelCacheEnable(); return result; } catch (CacheUnreachableException e) { setHighLevelCacheDisable(); } } return null; }
2
public static void concatenateFile(String... filename) { String str = null; // use try-with-resources // so no need to worry about closing the resources try (BufferedWriter writer = new BufferedWriter(new FileWriter( "CombinedFile.txt"));) { for (String name : filename) { try (BufferedReader reader ...
4
protected void initDefaultCommand() { setDefaultCommand(new SetModeMoving()); }
0
public static Tile nearestOpenTile(Monster movingMonster, char direction){ char left=direction; char right=direction; while(!canMove(movingMonster, direction)){ switch(randGenerator.nextInt(2)){ //at random, choose one of two actions: case(0): //action 1: try moving left. otherwise, move right. lef...
9
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
6
@Override public int[] decodeQuality(String quality) throws QualityFormatException { int[] qual = new int[quality.length()]; for (int i = 0; i < qual.length; i++) { int c = quality.charAt(i); int q = c - encoding.getOffset(); if ((q < encoding.lowerBound) || (q > encoding.upperBoud)) { throw new Quali...
3
public static void sendSay(MapleCharacter player, String msg) { MaplePacket packet; switch (player.getGMLevel()) { case 0: packet = MaplePacketCreator.serverNotice(5, "[Rookie ~ " + player.getName() + "] " + msg); break; case 1: pac...
5
synchronized public static ProcessManager getInstance() { if (singleton == null) { singleton = new ProcessManager(); } return singleton; }
1
@Override public void callback(DiscreteEventSimulator DES) throws SimulatorException { // Currently, the presence of a guest thread *always* preempts the native thread Machine machine = context.sim.getMachine(); CoreModel coreModel = machine.getCore(context); // Quit trying to simulate if disabled. if ...
9
@Override public void move() { super.move(); this.age += 1; }
0
private static void expandNode (final Problem problem, final Node node, final PriorityQueue<Node> frontier, final HashSet<Object> explored) { // Get all successors of the node. final List<Successor> successorSet = problem.getSuccessors(node.getState()); for (Successor...
6
public void deleteOldValues(final long now) { this.checkTime(now); final long minTime = now - this.windowLength; boolean deleted = false; while (this.size > 0) { if (this.times[this.ringTail] < minTime) { final float value = this.values[this.ringTail]; this.delete(); deleted = true; ...
9
private boolean[] checkNeighbours(int row, int col) { boolean isUp = false; boolean isDown = false; boolean isLeft = false; boolean isRight = false; if (row == 0) { isDown = true; } if (col == 0) { isRight = true; } if (row == this.getFieldWidth() - 1) { isUp = true; isDown = false; }...
8
public String getData(String email){ JSONArray result = new JSONArray(); ResultSet resultSet = null; try { // Get Connection and Statement connection = dataSource.getConnection(); statement = connection.createStatement(); String query2 = "select * from usuarios where email= '" + email + "'...
9
public static String lookupColumnName(ResultSetMetaData resultSetMetaData, int columnIndex) throws SQLException { String name = resultSetMetaData.getColumnLabel(columnIndex); if (name == null || name.length() < 1) { name = resultSetMetaData.getColumnName(columnIndex); } return name; }
2
public static DisplayMode getPreferredDisplay() throws LWJGLException { DisplayMode chosen = Display.getDisplayMode(); DisplayMode[] modes = Display.getAvailableDisplayModes(); for(DisplayMode display : modes){ if(isDisplayModeBetter(chosen, display) == true){ chose...
2
private static int toIndex(Direction dir) { switch(dir) { case SOUTH: return 0; case NORTH: return 1; case WEST: return 2; case EAST: return 3; } return 0; }
4
@Override public boolean init(List<String> argumentList, DebuggerVirtualMachine dvm) { breakpointLinesToSet = new ArrayList<String>(); breakableLineNumbers = new ArrayList<String>(); for (int i = 1; i < dvm.getSourceLinesSize(); i++) { if (dvm.isBreakableLine(i)) { ...
5
private final String getChunk(String s, int slength, int marker) { StringBuilder chunk = new StringBuilder(); char c = s.charAt(marker); chunk.append(c); marker++; if (isDigit(c)) { while (marker < slength) { c = s.charAt(marker...
5
private boolean userInputChecker(String userInput) { boolean matchesInput = false; for (int loopCount = 0; loopCount < userInputList.size(); loopCount++) { if (userInput.equalsIgnoreCase(userInputList.get(loopCount))) { matchesInput = true; userInputList.remove(loopCount); loopCount--; } ...
2
protected void do_button_actionPerformed(ActionEvent e) throws UnknownHostException, IOException, InterruptedException { String ip = textIpRede.getText(); if (ip.length() < 4) { JOptionPane.showMessageDialog(null, "Informe um IP válido!"); } else { try { Utils utils = new Utils(); InputStream pi...
5
static void draw_edges(List<AsciiEdge> edges, List<String> nodeline, List<String> interline) { int index = 0; for (AsciiEdge edge : edges) { if (edge.mStart == edge.mEnd + 1) { interline.set(2 * edge.mEnd + 1, "/"); } else if (edge.mStart == edge.mEnd - 1) { ...
7
private static boolean equals(byte[] foo, byte[] bar){ if(foo.length!=bar.length)return false; for(int i=0; i<foo.length; i++){ if(foo[i]!=bar[i])return false; } return true; }
3
public int countRows(String query) { ResultSet rs = null; int rowCount = 0; try { Statement statement = conn.createStatement(); // select the number of rows in the table rs = statement.executeQuery(query); // get the number of rows from the result ...
5
public E dequeue() { if (dequeue >= 0 && dequeue < queue.getSize()) { final E returnValue = (E) queue.get(dequeue); dequeue++; return returnValue; } else { return null; } }
2
public static Matrix read(Configuration conf, Path... modelPaths) throws IOException { int numRows = -1; int numCols = -1; boolean sparse = false; List<Pair<Integer, Vector>> rows = Lists.newArrayList(); for(Path modelPath : modelPaths) { for(Pair<IntWritable, VectorWritable> row : n...
7
public void actionPerformed (ActionEvent e) { // On test si le pseudo fait un minimum 3 caractere et s'il est disponible via // program.availableNickname if (nickname.getText().length() > 2 && program.availableNickname(nickname.getText())) { program.setNickname(nickname.getText()); // On envoi un signa...
3
private Object[][][] toCompressedArray(List<Locatable>[][] grid) { Object[][][] newGrid = new Object[this.xNumCells][this.yNumCells][]; for (int xi = 0; xi < grid.length; xi++) { List<Locatable>[] xar = grid[xi]; for (int yi = 0; yi < xar.length; yi++) { ...
3
private final String htmlFilter( String line ) { if ( line == null || line.equals( "" ) ) { return ""; } line = replace( line, "&", "&amp;" ); line = replace( line, "<", "&lt;" ); line = replace( line, ">", "&gt;" ); line = replace( line, "\\\\", "...
2
private Object lookupItem(String pattern) { Object selectedItem = model.getSelectedItem(); // only search for a different item if the currently selected does not match if (selectedItem != null && startsWithIgnoreCase(selectedItem.toString(), pattern)) { return selectedItem; }...
5
public String preReportBySubmitted() { List<ClassObj> lstClass = mdClass.getAll(); List<ObjectiveObj> lstObjective = mdObjective.getAll(); List<TopicObj> lstTopic = new LinkedList<TopicObj>(); if(lstObjective.size() > 0){ lstTopic = mdTopic.getByObjective(lstObjective.get(0)....
8
public void setSelected(MoleculeComponent e) { System.out.println(">>>>>>>>> Set selected called for " + e); if (e == null) // If null, clear selection { if (selected != null) { if (selected.getClass() == Element.class) { elements.get(selected.getKey()).setSelected(false); // set the internal selec...
8
public Scoreboard(GUIComponentGroup superGroup) { super(superGroup); winnerText = new TextComponent(this, "You Win!"); winnerText.setFont(GraphicalFont.HugeFont); winnerText.setAlignment(TextComponent.H_CENTER, TextComponent.V_CENTER); winnerText.setBounds(this.getLocationX(), ...
3
@Override public void paint(Graphics g) { super.paint(g); int dDibuixRobot = 30; int dRec = 10; int dGetL = 60; int dGetB = 35; int dGetBd = 42; int dBpro = 30; int dBpro2 = dBpro-2; int dBliv = 49; int dBrec ...
6
@SuppressWarnings("rawtypes") public Validator createValidator(final Annotation annotation) { try { final Object validatorValue = ReflectionUtils.getAnnotationValue( annotation, "validator"); /* * Validator attribute exists on annotation, so try to instantiate * it and create a validator. If t...
6
public ArrayList<String> getTxtContent(File file){ ArrayList<String> txtList=new ArrayList<String>(); if ((!file.exists())||file==null) { return txtList; } String line=null; System.out.println(file); File[] files=file.listFiles(); if (files==null||files.length==0) { return txtList; } for (int i...
7
public List<String> playerWorlds(Player player){ List<String> worldList = new ArrayList<String>(); for (String worldN : plugin.mainWorlds){ String worldName = worldN + "_" + player.getName(); String currentdir = plugin.minecraft_folder; File folder = new File(currentdir + "/inactive/" + worldName); F...
3
@Override public void onMessage(MutableWebSocketFrame aFrame, WebSocketContext aContext) { SocketIoMessage message = decoder.decode(aFrame); if (LOG.isDebugEnabled()) { if (SocketIoMessage.Type.EVENT.equals(message.type) && message.data != null) { final JsonElement event ...
9
public String getIp() { return this.ip; }
0
private void jList1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jList1KeyPressed if (evt.getKeyCode() == KeyEvent.VK_ESCAPE && jList1.getSelectedValue() != null) { logger.log(Level.INFO, "Resetting backup selection..."); jList1.clearSelection(); } }...
2
private void btn_loginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_loginActionPerformed String id, senha; id = txt_id.getText(); senha = txt_senha.getText(); if(id.isEmpty() || senha.isEmpty()){ JOptionPane.showMessageDialo...
4
public CheckController1(File file) { String fileType = file.getName().split("\\.")[0].split("_")[0]; int fileNameSectionNumber = file.getName().split("\\.")[0].split("_").length; try { checkReport1 = new CheckReport1(file); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace();...
7
public Warehouse getWarehouse(long itemid, int branchid) { Warehouse warehouse = null; Connection con = null; Statement stmt = null; try { DBconnection dbCon = new DBconnection(); Class.forName(dbCon.getJDBC_DRIVER()); con = DriverManager.getConnection(dbC...
5
private ArrayList<String> getTreeLeafs(){ ArrayList<String> leafs = new ArrayList<>(); for(ArrayList<String> valueList : _tree.values()){ for(String value : valueList){ if(_tree.containsKey(value)) continue; if(leafs.contains(value)) continue; leafs.add(value); } } return leafs; }
4
private boolean getTWSUserNameAndPasswordFromArguments(String[] args) { if (isFIX()) { if (args.length == 5 || args.length == 6) { IBAPIUserName = args[3]; IBAPIPassword = args[4]; return true; } else { return false; ...
8
public static void main(String[] args){ Boat.createBoat("RaceBoat"); Boat boat = Boat.getInstance(); for(int i = 90; i<=270; i+=10){ try{ System.out.print("Setting rudder to " + i + " degrees."); boat.com.sendMessage("set rudder " + i); Thread.sleep(1000); }catch(Exception e){ e.printStac...
2
final void method996(int i, int i_86_, int i_87_, int i_88_, boolean bool, int i_89_, boolean bool_90_) { anInt1151++; int i_91_ = 256; if (bool_90_) { i_91_ |= 0x20000; } if (bool) { i_91_ |= 0x40000000; } i_88_ -= anInt1135; if (i_87_ == 1) { i -= anInt1139; for (int i_92_ = i; (i_92_ ^ 0x...
9
public static Obligation getInstance(Node root) throws ParsingException { URI id; int fulfillOn = -1; List assignments = new ArrayList(); AttributeFactory attrFactory = AttributeFactory.getInstance(); NamedNodeMap attrs = root.getAttributes(); try { id = new...
9
public PropertyList lookupHandler(String path) { { HttpServer server = this; if (Http.$HTTP_SERVER_IMPLEMENTATION$ == null) { throw ((StellaException)(StellaException.newStellaException("lookup-handler: no HTTP server implementation loaded").fillInStackTrace())); } { PropertyList handler ...
6
public final void with_stmt() throws RecognitionException { try { // Python.g:274:10: ( 'with' test ( with_var )? COLON suite ) // Python.g:274:12: 'with' test ( with_var )? COLON suite { match(input,96,FOLLOW_96_in_with_stmt2191); if (state.failed) return; pushFollow(FOLLOW_test_in_with_stmt2193); ...
9
@SuppressWarnings("unchecked") public void initializeConfigValues() { Ore_Gin_Properties = new HashMap<Integer,OreGinProperties>(); Cloaker_Properties = new HashMap<Integer,CloakerProperties>(); //Load general config MachineFactoryPlugin.CITADEL_ENABLED = getConfig().getBoolean("general.citadel_enabled"); ...
8
public static Object getObject( Object in ) { // do not record -- only called from other methods if( !(in instanceof String) ) { return in; } String input = String.valueOf( in ); Object ret = input; // default is the original string try { ret = new Double( input ); return ret; } catch( N...
9
public void wyslijWiadomosc(String _wiadomosc, String _typWiadomosci) { try { if(socket != null) out = new PrintWriter(socket.getOutputStream()); } catch (IOException e) {System.out.println("Błąd WysWiad: "+e.getMessage()); } ...
6
public void run() { DNSOutgoing out = null; try { // send probes for JmDNS itself if (this.jmDNSImpl.getState() == taskState) { if (out == null) { out = new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DN...
9
public void setInputParamInteger(final int paramIndex, final Object array) throws IllegalArgumentException, NullPointerException { if (array==null) throw new NullPointerException(ARRAY_IS_NULL); InputParameterInfo param = getInputParameterInfo(paramIndex); if ((param==null) || (param.type()!=Inp...
5
private String getDirectory() { if ((config.getDirectory() == null) || (config.getDirectory().isEmpty())) return "logfiles/"; else return config.getDirectory() + "/"; }
2
@PostConstruct @Schedule( year="*", dayOfWeek="*" , hour="*" , minute="*/5" , persistent=false ) @Timeout @AccessTimeout(unit=TimeUnit.MINUTES, value=1) private void loadFeaturedItem(Timer timer){ System.out.println(" #### Iniciando el FeaturedItemBean.loadFeaturedItem() "); this.featuredItems = new Array...
2
private void registerNew() { if (registerQueue.isEmpty()) return; Selector selector = this.selector; for (;;) { RegistrationRequest req = registerQueue.poll(); if (req == null) break; DatagramSessionImpl session = new DatagramSes...
6
private boolean jj_2_51(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_51(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(50, xla); } }
1
private void connect() { do { try { connection = (TACConnection) Class.forName(connectionClassName). newInstance(); } catch (Exception e) { log.log(Level.SEVERE, "could not create TACConnection object of class " + connectionClassName, e); fatalError("no TACConnection available"); } ...
5
@AfterTest @Test(groups = "Deletion") public void testRandomBSTDeletion() throws KeyNotFoundException, EmptyCollectionException { Reporter.log("[ ** Random BST Deletion ** ]\n"); Integer count = 0; timeKeeper = System.currentTimeMillis(); for (Integer i = -seed; i < 0; i++) { try { randomBST.del...
6
public static void startupUtilitiesSystem() { synchronized (Stella.$BOOTSTRAP_LOCK$) { if (Stella.currentStartupTimePhaseP(0)) { if (!(Stella.systemStartedUpP("stella", "/STELLA"))) { StartupStellaSystem.startupStellaSystem(); } } if (Stella.currentStartupTimePhaseP(1)) {...
9
public Method findMethod(String prefix, String methodName, Class<?> ... paramType) { if(methodName == null || methodName.isEmpty()) return null; methodName = createMethodName(prefix, methodName); try { return getInspectedClass().getDeclaredMethod(methodName, paramType); } catch (SecurityException e) { ...
5
public void visitLocalExpr(final LocalExpr expr) { if (expr.fromStack()) { print("T"); } else { print("L"); } print(expr.type().shortName().toLowerCase()); print(Integer.toString(expr.index())); final DefExpr def = expr.def(); if ((def == null) || (def.version() == -1)) { print("_undef"); }...
3
public void update() { statusPanel.setText(status.getText()); repaint(); if(player.hasWon() && !player.getWinnerMessageHasBeenShown() && !grid.getIsTest()){ showWinMessage(); } }
3
public boolean unequip(final int... ids) { // Disable when bank open if (ctx.bank.opened()) { return false; } if (ctx.hud.open(Hud.Window.WORN_EQUIPMENT)) { final Item item = ctx.equipment.select().id(ids).poll(); if (item.valid()) { if (item.interact("Remove")) { return Condition.wait(new Ca...
4
private String scanDirectiveIgnoredLine(Mark startMark) { // See the specification for details. int ff = 0; while (reader.peek(ff) == ' ') { ff++; } if (ff > 0) { reader.forward(ff); } if (reader.peek() == '#') { ff = 0; ...
6
private void showEduFw() { content = null; head = null; Object fb = logic.showEduFwHead(); if (fb instanceof Feedback) { JOptionPane.showMessageDialog(null, ((Feedback) fb).getContent()); } else if (fb instanceof String[]) { head = (String[]) fb; fb = logic.showEduFwContent(); if ((fb instanceof ...
9
public static int getLevenshteinDistance(String s, String t) { if (s == null || t == null) { throw new IllegalArgumentException("Strings must not be null"); } /* The difference between this impl. and the previous is that, rather than creating and retaining a matrix of size s.length()+1 by t.length()+1, ...
8
public EncryptedHand decyrptEncHand(EncryptedHand hand) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { EncryptedHand ret = new EncryptedHand(); for (int i = 0; i < Hand.NUM_CARDS; i++) { EncryptedCard tmp = hand.data.get(i); ret.data.add(decryptEncCard(tmp)); } retur...
1
public static boolean isInteger(String str) { if (str == null) { return false; } int length = str.length(); if (length == 0) { return false; } int i = 0; if (str.charAt(0) == '-') { if (length == 1) { return false; } i = 1; } for (; i < length; i++) { char c = str.charAt(i); i...
7
public void save() { if (config == null || file == null) { return; } try { get().save(file); } catch (IOException ex) { InstaScatter.ins.getLogger().log(Level.SEVERE, "Could not save config to " + file, ex); } }
3
public String printTree(int depth) { String print = ""; for (int i = 0; i < depth; i++) { print = print + " "; } print = print + toString() + "\n"; Binomialnode a = child; while (a != null) { print = print + a.printTree(depth + 1); a...
2
@Override public Key next() { if (!hasNext()) throw new NoSuchElementException(); Node node = stack.pop(); if (node.right != null) stack.push(node.right); if (node.left != null) stack.push(node.left); return node.key; }
3
public void removeByFileName(String song) { if(playList != null) { GameSong gs; for(int i = 0; i < playList.size(); i++) { gs = playList.get(i); if(gs.getFilePath().equals(song)) { if(currentSongIndex == i) { if(...
7
public synchronized void threadInc(SimThread t, DataHolder d) { if (Constants.muCheck) { if ((Constants.muIncS += Constants.muIncUp) < .75) { t.Constants._epsilon = this.epsilon; t.Constants._SIM_epsilon_start = this.epsilon; t.Constants._SIM_epsilon_final = this.epsilon; t.setRunNum(runNum); r...
5
public Meeting getMeeting(int id) { MeetingImpl tempM = null; for(Meeting m : meetingList) { tempM = (MeetingImpl) m; if(tempM.meetingID==id) { return m; } } return null; }
2
public LongCount(int bak, int kat, int tun, int win, int ki) { if(bak < 0) { throw new IllegalArgumentException("Baktuns must be greater than or equal to 0."); } if(kat < 0 || kat > 19) { throw new IllegalArgumentException("Katuns must be a number 0-19 inclusive."); } if(tun < 0 || tun > 19) { ...
9
private void toNote() { ItemDefinition noteTemplateDefinition = getDefinition(noteTemplateId); modelId = noteTemplateDefinition.modelId; modelZoom = noteTemplateDefinition.modelZoom; modelRotationX = noteTemplateDefinition.modelRotationX; modelRotationY = noteTemplateDefinition.modelRotationY; modelRotatio...
5
public static double getDistance(ClusterPoint p1, ClusterPoint p2, int distanceType) { double sum = 0.0; switch(distanceType) { case MANHATTEN: for(int i = 0; i < p1.getDimensionSize(); i++) sum += Math.abs(p2.getValueAtDimension(i) - p1.getValueAtDimension(i)); return sum; case EUC...
4
public final void run() throws FatalError { printJump("(" + count + ")"); // cut it into parts to safe session int c = count; while (c > 10) { // sleep for 10 min Control.sleep(6000, 2); c -= 10; Control.current.getCharacter(); } Control.sleep(600 * c, 2); }
1
public Object nextValue() throws JSONException { char c = nextClean(); String string; switch (c) { case '"': case '\'': return nextString(c); case '{': back(); return new JSONObject(this); case '[': ...
7
public final TLParser.assignment_return assignment() throws RecognitionException { TLParser.assignment_return retval = new TLParser.assignment_return(); retval.start = input.LT(1); Object root_0 = null; Token Identifier15=null; Token char_literal17=null; TLParser.indexe...
5
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int length = to.length(); char[] circle = new char[length]; /* * First fill the circle buffer with as many characters as are in the ...
9
public void printScreen(byte[] screen, int width){ int bytesPerLine = width/8; int height = screen.length / bytesPerLine; for(int i = 0; i < height; i++){ //print each line; int startByteIndex = i*bytesPerLine; int endByteIndex = startByteIndex + bytesPerLine-1; for(int j = startByteIndex; j<=endBy...
2
private Thread searchThreadsInSubGroup(final String threadName, final ThreadGroup group, final int level) { ThreadGroup[] groups = new ThreadGroup[group.activeGroupCount() * 2]; int numGroups = group.enumerate(groups, false); Thread thread = null; for (int i = 0; i < numGroups && thread == null; i++) { thre...
2
public static int uniquePaths(int m, int n) { int[][] path = new int[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (0 == i && 0 == j) path[i][j] = 1; else if (0 == i) path[i][j] = path[0][j - 1]; else if (0 == j) path[i][j] = path[i - 1][0]; else path[...
6
public static S3Bucket[] listAllBuckets(RestS3Service s){ S3Bucket[] s3buckets= null; try { s3buckets = s.listAllBuckets(); } catch (S3ServiceException e) { e.printStackTrace(); } return s3buckets; }
1
private void makeFlushStates() { for (int cn0 = 0; cn0 < RANK_SIZE; cn0++) { for (int cn1 = cn0 + 1; cn1 < RANK_SIZE; cn1++) { for (int cn2 = cn1 + 1; cn2 < RANK_SIZE; cn2++) { for (int cn3 = cn2 + 1; cn3 < RANK_SIZE; cn3++) { for (int cn4 = cn3 + 1; cn4 < RANK_SIZE; cn4++) {...
9
public String[] mapTypes(String[] types) { String[] newTypes = null; boolean needMapping = false; for (int i = 0; i < types.length; i++) { String type = types[i]; String newType = map(type); if (newType != null && newTypes == null) { newTypes = new String[types.length]; if (i > 0) { System.a...
7
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String del = (String) req.getParameter("del"); if(del != null && del.equals("yes")){ log.info("remove file"); MatchUtil.removeFile(); } String time = (Strin...
6
public void settle(){ int buyquant = Integer.parseInt(buynumber.getText()); int sellquant = Integer.parseInt(sellnumber.getText()); int type_int = type.getSelectedIndex()+1; int current = sector.getQuantity(type_int); int checkCap = Empous.Gov.getStat("reserve") - sum[0][0]; int checkWood = Empous.Gov.ge...
3