text stringlengths 14 410k | label int32 0 9 |
|---|---|
public void updateLed(double rpm) {
if (rpm >= rpmForPin1 && rpm < rpmForPin2) {
stopBlinking();
pin1.high();
pin2.low();
pin3.low();
} else if (rpm >= rpmForPin2 && rpm < rpmForPin3) {
stopBlinking();
pin1.high();
pin2.high();
pin3.low();
} else if (rpm >= rpmForPin3 && rpm < rpmForBlinki... | 8 |
public static String getPK3MapNames(String pathToFile) {
ZipFile zip;
try {
zip = new ZipFile(pathToFile);
} catch (IOException e2) {
e2.printStackTrace();
return null;
}
Enumeration<? extends ZipEntry> e = zip.entries();
String mapNames = "";
while (e.hasMoreElements()) {
ZipEntry ze = (ZipEn... | 6 |
private void PageRedirect(String itemID, String itemType, String query, boolean DisplayGO, boolean organismdependentquery) {
if (applet == null || configuration == null)
return;
String wholeredirectionString = getRedirectionString(itemID, itemType, query, DisplayGO, organismdependentquery... | 8 |
public void setNeighbors( int[] truckdrivin){
//System.out.println(truckdrivin.length);
//System.out.println(neighborstate.length);
for(int g = 0; g <= truckdrivin.length-1; g++){
switch(inmode){
case 0: neighborstate[g] = 0; break;
case 1: if(truckdrivin[g] > 0){neighborstate[g] = 1;}
else{neighb... | 5 |
public String toString()
{
if (titulo != null)
return titulo.toString();
return id + "";
} | 1 |
public static void main(String[] args) throws Exception
{
CalendarProject myCalendar = new CalendarProject (2013,2);//'0' indicates the first day of the year is a sunday;
} | 0 |
public double sin(int a){
//normalizing
if(a>360){
a %= 360;
}else if(a<0){
a %= 360;
a += 360;
}
//return
if(a <= 90){
return sin[a];
}else if(a <= 180){
return sin[180 - a];
}else if(a <= 270){
return -sin[a - 180];
}else{
return -sin[360 - a];
}
} | 5 |
@Override
public AState breakTie(AState state1, AState state2)
{
if(state1.getG() > state2.getG())
return state1;
else
return state2;
} | 1 |
public static ComponentUI createUI(JComponent c) {
return new BasicScrollBarUI();
} | 0 |
@Override
public Set<String> getGroups() {
return getList("groups");
} | 0 |
private static String encode_base64(byte d[], int len)
throws IllegalArgumentException {
int off = 0;
StringBuffer rs = new StringBuffer();
int c1, c2;
if (len <= 0 || len > d.length)
throw new IllegalArgumentException ("Invalid len");
while (off < len) {
c1 = d[off++] & 0xff;
rs.append(base64_co... | 5 |
public JTextComponent getReplacementArea() {
if(replacementArea == null) {
replacementArea = new JTextArea();
replacementArea.setLineWrap(true);
replacementArea.setFont(textAreaFont);
replacementArea.setEditable(false);
replacementArea.setBackground(Color.LIGHT_GRAY);
// U... | 3 |
public void start() {
closeDoors();
closeWindows();
} | 0 |
public AdjacencyList getMinBranching(Node root, AdjacencyList list) {
AdjacencyList reverse = list.getReversedList();
// remove all edges entering the root
if (reverse.getAdjacent(root) != null) {
reverse.getAdjacent(root).clear();
}
AdjacencyList outEdges = new Adjac... | 9 |
public static int result(String[] token){
Stack<String> stack = new Stack<String>();
String oprator ="+-*/";
for(String str : token){
if(!oprator.contains(str)){
stack.push(str);
}else{
int a = Integer.valueOf(stack.pop());
int b = Integer.valueOf(stack.pop());
int c = 0;
switch(st... | 6 |
public synchronized void plot(double[][] xyValues, Color color) {
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g.setStroke(new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g.setColor(color);
line.moveTo(xyValues[0][0], xyValues[1][0]);
for(int i =... | 5 |
@Override
public void update(Updater u) {
// a monster has gravity too, as a everything on earth (except light, but light doesn't have mass. Or has it ?
this.speedY += LivingEntity.GRAVITY;
// and he moves in one direction
if (this.direction)
this.speedX = LivingEntity.WALKSPEED;
else
this.speedX = ... | 2 |
static void shared() {
int oldVal;
lock.lock();
try {
oldVal = x;
x ++;
} finally {
lock.unlock();
}
System.out.println(Thread.currentThread().getName() + ":" + oldVal);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// if (lock.tryLock()) {
//... | 1 |
double[][] findEdges(double[][] smoothedGray) {
double[][] edges = new double[smoothedGray.length][smoothedGray[0].length];
for(int x = 0; x < edges.length; ++x) {
for(int y = 0; y < edges[x].length; ++y) {
if(x < 1 || x >= edges.length - 1 || y < 1 || y >= edges[x].length - 1) {
edges[x][y] = 0;
c... | 6 |
@Test
public void clientIdIsMax23Characters() {
// This should work
new ConnectMessage("12345678901234567890123", false, 10);
try {
// This should not work;
new ConnectMessage("123456789012345678901234", false, 10);
fail();
} catch (IllegalArgumentException e) {
}
} | 1 |
protected Integer calcBPB_RootEntCnt() throws UnsupportedEncodingException {
byte[] bTemp = new byte[2];
for (int i = 17;i < 19; i++) {
bTemp[i-17] = imageBytes[i];
}
BPB_RootEntCnt = byteArrayToInt(bTemp);
System.out.println(BPB_RootEntCnt);
return BPB_RootEn... | 1 |
private boolean output(int regNum)
{
boolean found = false;
int index = 0;
//searching for an available output card
while(!found && index < outputCards.registers.length)
{
if(outputCards.registers[index].text.getText().equals(""))
{
... | 4 |
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final XMLElement other = (XMLElement) obj;
if (this.element != other.element && (this.element == null || !this.... | 5 |
public void clear() {
count = 0;
for (int n=0; n < this.cap; n++) {
keys[n] = null;
}
int cap2 = cap << 2;
for (int n=0; n < cap2; n++) {
hopidx[n] = 0;
}
} | 2 |
@Test
public void canGetWord_whenWordExist() {
trie.add("abc");
assertTrue(trie.contains("abc"));
} | 0 |
* @param outputLocation - location to extract to
*/
public static void extractZipTo (String zipLocation, String outputLocation) {
ZipInputStream zipinputstream = null;
try {
byte[] buf = new byte[1024];
zipinputstream = new ZipInputStream(new FileInputStream(zipLocation)... | 8 |
@Basic
@Column(name = "username")
public String getUsername() {
return username;
} | 0 |
public static void LSDsort(String[] a, int W) {
int N = a.length;
int R = 256;
String[] aux = new String[N];
// key indexed counting for each digit from right to left
for (int d = W - 1; d >= 0; d--) {
int[] count = new int[R + 1];
// count frequencies
for (int i = 0; i < N; i++)
count[a[... | 5 |
@Override
public void fatalError(JoeException someException) {
System.out.println(someException.getMessage()) ;
this.errorOccurred = true;
} // end method fatalError | 0 |
public void run() {
init();
this.requestFocus();
long startTime = System.nanoTime();
long previousTime = System.nanoTime();
long tempTime = System.nanoTime();
long currentTime;
double updateRate = 60.0;
long ns = 1000000000;
double delta = 0;
... | 4 |
public boolean login(String userID, String password) {
// TODO Auto-generated method stub
if (getFact.login(userID, password)) {
return true;
}
else
return false;
} | 1 |
public BookReader(String filename)
{
super(filename); //does nothing
//read in book - set book to "" if not found
Scanner input;
book = new ArrayList<String>();
try
{
input = new Scanner(new File(filename));
System.out.println("Loaded book.");
}
catch (Exception e)
{
System.out.println("... | 9 |
public void run() {
while (listen) {
try {
int encryptedSize = inStream.readInt();
int rawSize = inStream.readInt();
byte[] message = new byte[encryptedSize];
int readSoFar = 0;
while (readSoFar < encryptedSize)
readSoFar += inStream.read(message, readSoFar,
message.length - readSoF... | 9 |
public void setSecondElement(T newSecond) {
if (newSecond == null) {
throw new NullPointerException();
}
this.secondElement = newSecond;
} | 1 |
public static String toString(JSONObject jo) throws JSONException {
StringBuffer sb = new StringBuffer();
sb.append(escape(jo.getString("name")));
sb.append("=");
sb.append(escape(jo.getString("value")));
if (jo.has("expires")) {
sb.append(";expires=");
s... | 4 |
public int getPoints() {
int points = 0;
for (Card c : myCards) {
points += c.getFaceValue();
}
if (points > 21 && (this.numberOfAces() >= 1))
points -= 10;
if (points > 21 && (this.numberOfAces() >= 2))
points -= 10;
if (points > 21 && (this.numberOfAces() >= 3))
points -= 10;
if (points > ... | 9 |
@Override
public WorkSheetHandle[] getWorkSheets()
{
try
{
if( myfactory != null )
{
int numsheets = mybook.getNumWorkSheets();
if( numsheets == 0 )
{
throw new WorkSheetNotFoundException( "WorkBook has No Sheets." );
}
WorkSheetHandle[] sheets = new WorkSheetHandle[numsheets];
... | 4 |
private ControlLogCaptureTypeMessage getLevel() {
if (verbose.isSelected()) {
return ControlLogCaptureTypeMessage.VERBOSE;
} else if (info.isSelected()) {
return ControlLogCaptureTypeMessage.INFO;
} else if (warning.isSelected()) {
return ControlLogCaptureTypeMessage.WARN;
} else {
return ControlLog... | 3 |
@Override
protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice)
{
super.onNotice(sourceNick, sourceLogin, sourceHostname, target, notice);
int i = 0;
Main.debug("Check! " + sourceNick + ", " + target + ", " + notice);
while(true)
{
Main.debug(... | 4 |
private void drawCurrentLocation(Graphics2D g2)
{
if ("hide".equals(System.getProperty("info.gridworld.gui.selection")))
return;
if (currentLocation != null)
{
Point p = pointForLocation(currentLocation);
g2.drawRect(p.x - cellSize / 2 - 2, p.y - cellSize ... | 2 |
private void loginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginActionPerformed
try {
// TODO add your handling code here:
//System.out.println(username.getText());
//System.out.println(password.getText());
String name=username.getText();
... | 5 |
public Object getFontSmoothingValue()
{
switch(font_smoothing_value)
{
default:
case 0:
return RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
case 1:
return RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
case 2:
return RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
... | 8 |
public String getServiceEmployeeId() {
return serviceEmployeeId;
} | 0 |
private void prepareFiguresChain(FiguresChain figuresChain) {
if (Objects.isNull(Chessboard.this.figureChain)) {
Chessboard.this.figureChain = figuresChain;
previousFiguresChain = figuresChain;
} else {
previousFiguresChain.setNextFigure(figuresCha... | 1 |
public List<AlbumType> getAlbum() {
if (album == null) {
album = new ArrayList<AlbumType>();
}
return this.album;
} | 1 |
private boolean checkLeft(int x, int y, int z){
int dz = z + 1;
if(dz > CHUNK_WIDTH - 1){
return false;
}else if(chunk[x][y][dz] != 0){
return true;
}else{
return false;
}
} | 2 |
public Stencils()
{
super("Stencils");
try
{
String filename = Stencils.class.getResource(
"/com/mxgraph/examples/swing/shapes.xml").getPath();
Document doc = mxXmlUtils.parseXml(mxUtils.readFile(filename));
Element shapes = doc.getDocumentElement();
NodeList list = shapes.getElementsByTagName... | 6 |
public static int minDepthOf(Node root) {
if(root == null)
return -1;
if(root.left == null && root.right == null)
return 0;
else if(root.left == null)
return 1+minDepthOf(root.right);
else if(root.right == null)
return 1+minDepthOf(root.left);
else
return (minDepthOf(root.left)>minDepthOf(ro... | 6 |
@Override
public boolean runsIntoBidimensional(Individual otherI) {
return (super.getX()==otherI.getX() || this.x1==otherI.getX() || super.getX()==otherI.getX1()) &&
(super.getY()==otherI.getY() || this.y1==otherI.getY() || super.getY()==otherI.getY1());
} | 5 |
public static File resolve(String file, File out) {
File f = new File(file);
if (!(f.isAbsolute() && f.exists())) {
f = new File(out, file);
}
if (!f.exists()) {
throw new IllegalArgumentException("File not found: " + file);
}
return f;
} | 3 |
public static void main(String[] args) throws IOException {
path = "c:\\Users\\Djordje\\Dropbox\\Matlab\\H-GCRF_HCUP_v2.1_yearly\\pctdata\\grid_sid_yearly\\";
loadProperties(path + "\\size.properties");
Runtime rt = Runtime.getRuntime();
long totalMem = rt.totalMemory();
long ... | 9 |
public ResultSet selectAll()
{
ResultSet results=null;
if(conn!=null){
try
{
stmt = conn.createStatement();
results = stmt.executeQuery("select * from " + table_name);
results.close();
stmt.close();
}
catch (SQLExcepti... | 2 |
@Override
public void ParseIn(Connection Main, Server Environment)
{
Room Room = Environment.RoomManager.GetRoom(Main.Data.CurrentRoom);
if (Room == null)
{
return;
}
String NewMotto = Main.DecodeString();
if(Main.Data.Motto.equals(NewMotto))
... | 3 |
public static LDAPUser getUserInfo(String crsid){
LDAPUser result = new LDAPUser();
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://ldap.lookup.cam.ac.uk:389");
Attributes a = null;
try{
D... | 5 |
protected void jump() {
if (!airborne)
jumping = true;
} | 1 |
private void refreshInformation() {
for (final File fileEntry : folder.listFiles()) {
StringBuffer content = new StringBuffer();
try {
FileReader fr = new FileReader(fileEntry.getAbsolutePath());
BufferedReader br = new BufferedReader(fr);
String line ="";
while ((line = br.readLine()) != null)... | 4 |
private void parseStatus(UserState status, Map<String, Object> pageVariables) {
switch (status) {
case EMPTY_DATA:
case FAILED_AUTH:
case NO_SUCH_USER_FOUND:
case SQL_ERROR:
case USER_ALREADY_EXISTS:
pageVariables.put("errorMsg", status... | 8 |
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 |
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 |
public List<Case> getLiberte(){
Set<Case> libSet = new HashSet<>();
for (Case c1 : pierres){
for(Case c : (ArrayList<Case>)this.g.getCasesAutourDe(c1)){
if (c.caseLibre()){
libSet.add(c);
}
}
}
return new ArrayLi... | 3 |
public String getName() {
return name;
} | 0 |
int test2( ) throws MiniDB_Exception{
MiniDB db, db2;
BPlusTree bpt;
int points = 0, maxPoints = 5;
Random rng = new Random();
db = makeNewDB("test2.1" );
//
int recSize = 50;
String indexingFile = "file2.";
String indexedField = "field2.";
BPlusTree bpt50 = db.createNew... | 5 |
public User login(String username, String password, String forumId) {
for (int i = 0; i < forums.size(); i++) {
if (forums.get(i).getId().equals(forumId))
return forums.get(i).login(username, password);
}
return null;
} | 2 |
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 |
public int getCard(int id) {
for (int i = 0; i < cards.length; i++) {
if (id == cards[i]) {
return i + 1;
}
}
return 0;
} | 2 |
private void buttonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSearchActionPerformed
String searchQuery = textSearch.getText().toUpperCase();
String agcoopCompany = "maininterface.ViewCompany";
String agcoopMember = "maininterface.ViewMember";
... | 5 |
public Integer[] getParticipantsCount (Date d) {
Integer pc[] = {0, 0, 0, 0, 0, 0};
for (Trip t: getAllTrips(d)) {
River r = t.getRiver();
if (r != null) {
int ww = t.getRiver().getWwTopLevel()-1;
pc[ww] = pc[ww]+t.getGroupSize();
}
}
return pc;
} | 2 |
private void initPotential() {
for (int i = 0; i < MicromouseRun.BOARD_MAX; i++) {
for (int j = 0; j < MicromouseRun.BOARD_MAX; j++) {
potential[i][j] = MicromouseRun.BOARD_MAX * MicromouseRun.BOARD_MAX + 1;
}
}
} | 2 |
private void initDragAndDrop() {
smartFolderTree.setDropTarget(new DropTarget() {
@Override
public synchronized void drop(DropTargetDropEvent dtde) {
try {
Transferable transfer = dtde.getTransferable();
if (transfer.isDataFlavorSu... | 5 |
private void init(ForecastIO fio){
if(fio.hasFlags()){
if(fio.getFlags().names().contains("darksky-unavailable"))
this.flags.put("darksky-unavailable", toStringArray(fio.getFlags().get("darksky-unavailable").asArray()));
if(fio.getFlags().names().contains("darksky-stations"))
this.flags.put("darksky-s... | 9 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof User))
return false;
User other = (User) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if ... | 9 |
@Override
public void setAmmoRemaining(int amount)
{
final int oldAmount=ammunitionRemaining();
if(amount==Integer.MAX_VALUE)
amount=20;
setUsesRemaining(amount);
if((oldAmount>0)
&&(amount==0)
&&(ammunitionCapacity()>0))
{
boolean recover=false;
for(final Enumeration<Ability> a=effects();a.has... | 9 |
@Override
public void store() {
Map<Class<? extends Material>, List<Map<String, Object>>> description
= new HashMap<Class<? extends Material>, List<Map<String, Object>>>();
for (Material m : this.stockToList()) {
Class<? extends Material> c = m.getClass();
if (description.containsKey(c)) {
descr... | 5 |
public Clock getClockForGroup() {
return clockForGroup;
} | 0 |
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
String player = "x";
TicTacToe game = new TicTacToe();
boolean done = false;
while(!done)
{
System.out.println(game.toString());
System.out.println("Row for " + playe... | 9 |
public void paintComponent( java.awt.Graphics g )
{
if ( !(drawStripes = isOpaque( )) )
{
super.paintComponent( g );
return;
}
// Paint zebra background stripes
updateZebraColors( );
final java.awt.Insets insets = getInsets( );
final ... | 4 |
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
ContaPagar ContaPagar = filtrados.get(rowIndex);
switch (columnIndex) {
// "ID","Cliente","Data","Vencimento","Observação","Valor","Pago"};
case 0:
return ContaPagar.getId();
... | 9 |
* @return Whether, given the two undo patches, they should be merged
* instead of pushing the new one.
* @note It is immaterial which UndoPatch is newer.
*/
private static boolean undoCompatible(UndoPatch up1, UndoPatch up2) {
if ((up1.opTag != up2.opTag && up2.opTag != OPT.SPACE) || up1.startRow... | 6 |
public static boolean isBalanced(String brackets) {
if (brackets == null || brackets.isEmpty()) {
return true;
}
if (brackets.contains("()")) {
return isBalanced(brackets.replaceFirst("\\(\\)", ""));
}
if (brackets.contains("[]")) {
return isBa... | 5 |
private Integer pickItemInList(Collection<BorrowableStock> list) {
String input = null;
Boolean valid = false;
while (!valid) {
System.out.println("Select an item in the following list :");
for (BorrowableStock b : list) {
String borrowableName = b.getNam... | 6 |
public boolean isValidType() {
return ifaces.length == 0 || (clazz == null && ifaces.length == 1);
} | 2 |
static int swap(int x, int k){
int pos = 0;
while((x/pow[pos])%10>0){
pos++;
}
int tp = 0;
if(k==0){
if(pos+4>7)return 0;
tp = pos+4;
}
else if(k==1){
if((pos+1)%4==0)return 0;
tp = pos+1;
}
else if(k==2){
if(pos-4<0)return 0;
tp = pos-4;
}
else if(k==3){
if(pos%4==0)return... | 9 |
public static String selectListPageParam(Map<String, Object> paramMap) throws SQLException{
@SuppressWarnings("unchecked")
java.util.Map<String,Object> sqlWhereMap = (Map<String, Object>) (paramMap.get("sqlWhereMap")==null ? "": paramMap.get("sqlWhereMap"));
BEGIN();
SELECT(Permission.COLUMNS);
... | 3 |
@Override
public void keyReleased(int keyCode, char keyChar) {
if(keyCode == 200) {
if(!player.isMoving) {
player.isMoving = false;
}
}
if(keyCode == 203) {
if(!player.isMoving) {
player.isMoving = false;
}
}
if(keyCode == 205) {
if(!player.isMoving) {
player.isMoving = false;
}... | 8 |
private boolean jj_2_53(int xla) {
jj_la = xla; jj_lastpos = jj_scanpos = token;
try { return !jj_3_53(); }
catch(LookaheadSuccess ls) { return true; }
finally { jj_save(52, xla); }
} | 1 |
public String toSQL() {
if (this.hasParameters()) {
throw new RuntimeException("parameters in SQL not set");
} else {
if (this.sqlCache == null) {
this.sqlCache = builder.toString();
}
return sqlCache;
}
} | 2 |
public void print() {
System.out.println();
System.out
.println("Number \t Head \t Tail \t Type \t Dest \t Value \t Ready \t");
System.out
.println("----------------------------------------------------------------------- ");
for (int i = 0; i < tuples.length; i++) {
ROBTuple tuple = tuples[i];
S... | 5 |
public static Cons cppGetParameterizedMemberVariableDefinitions(Stella_Class renamed_Class) {
{ Cons membervardefs = Stella.NIL;
{ Slot slot = null;
Cons iter000 = renamed_Class.classLocalSlots.theConsList;
Cons collect000 = null;
for (;!(iter000 == Stella.NIL); iter000 = iter000.res... | 6 |
public ArrayList<Guest> searchForGuestDB(String status, Connection con, String... names) {
Guest guest = null;
String SQLString = "";
ArrayList<Guest> guestList = new ArrayList<>();
if (status.equals("both")) {
SQLString = "SELECT * "
+ "FROM guests "
... | 7 |
@SuppressWarnings("unchecked")
public <D extends AbstractDAO> D findDAO(Class<D> clazz)
throws DBException
{
if (null == jdbc)
throw new DBException("Cannot attach DAO to " + this + ": database not open");
D dao = (D)daoMap.get(clazz);
if (null == dao)
{
try
{
Constructor<?> ctr = clazz.getD... | 9 |
@Override
protected PlayerStartPositionCTF createPlayerStartPosition(Player player) {
if (player == null)
throw new IllegalArgumentException("The given arguments are invalid!");
return new PlayerStartPositionCTF(grid, player);
} | 1 |
public static void main(String[] args) throws IOException {
try {
/* parse the command line arguments */
// create the command line parser
CommandLineParser parser = new PosixParser();
// create the Options
Options options = new Options();
options.addOption("h", "help", false, "");
options.addO... | 9 |
public static void main(String[] args) {
Map<String, Integer> tempMap = new HashMap<String, Integer>();
tempMap.put("a", 1);
tempMap.put("b", 2);
tempMap.put("c", 3);
// JDK1.4中
// 遍历方法一 hashmap entrySet() 遍历
System.out.println("方法一");
Iterator<Entry<String, Integer>> it = tempMap.entrySet().ite... | 9 |
public static void main(String[] args) {
ReadByteFile reader = new ReadByteFile("punches.png");
try {
punches = reader.openFile();
} catch (IOException ex) {
Logger.getLogger(PunchFormatter.class.getName()).log(Level.SEVERE, null, ex);
}
WriteByteFile writer = ne... | 2 |
private boolean searchWord(TrieNode _root, String _word) {
if(null == _root || null == _word || "".equals(_word))
return false;
char[] cs = _word.toCharArray();//将字符串转化为字符数组
for(int i = 0; i < cs.length; i++){
int index;
if(cs[i] >= 'A' && cs[i] <= 'Z'){
index = cs[i]-'A';
}
else if(cs[i] >... | 9 |
public void addFlyUp(String message) {
flyups.add(new FlyUp(message));
while(flyups.size() > 5) {
flyups.remove(0);
}
repositionFlyUps();
} | 1 |
private void createNodes(DefaultMutableTreeNode top) {
DefaultMutableTreeNode generalForums = null;
DefaultMutableTreeNode category = null;
DefaultMutableTreeNode subCategory = null;
DefaultMutableTreeNode question = null;
generalForums = new DefaultMutableTreeNode("General Foru... | 5 |
public Communication(){
try{
socket = new Socket("localhost", 5555);
transmit = new PrintWriter(socket.getOutputStream(), true);
receive = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
socket.setSoTimeout(60); //TODO Is that reasonable?
}catch(UnknownHostException | Socket... | 2 |
private boolean checkSquare(int check_index) {
HashMap<Integer, ServerThread> players_threads = Server.getPlayersThreads();
Element element = Server.board.getElement(check_index);
if (element != null && element.isActive()) {
if (!element.isBreakable()) {
return false... | 6 |
public static String encrypt(String string, String algo) {
if (!c.getID().equalsIgnoreCase(algo)) {
updateC(algo);
}
try {
c.setKey(key);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "This key is not valid.", "Invalid Key", JOptionPan... | 2 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.