This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.UnsupportedEncodingException; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
/** | |
* | |
* @author EtaYuy88 | |
*/ | |
public class Main { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Many network protocols and files store their characters with a byte-oriented character set such as ISO-8859-1 (ISO-Latin-1). However, Java's native character encoding is Unicode. | |
This example demonstrates how to convert ISO-8859-1 encoded bytes in a ByteBuffer to a string in a CharBuffer and visa versa. | |
In the example above, the encoding and decoding methods created new ByteBuffers into which to encode or decoding the data. Moreover, the newly allocated ByteBuffers are non-direct (Determining If a ByteBuffer Is Direct). The encoder and decoder provide methods that use a supplied ByteBuffer rather than create one. Here's an example that uses these methods: | |
*/ | |
// Create the encoder and decoder for ISO-8859-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getHexString(byte[] b) throws Exception { | |
String result = ""; | |
for (int i=0; i < b.length; i++) { | |
result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 ); | |
} | |
return result; | |
} | |
public static byte[] getByteArray(String hexString) { | |
return BigInteger(hexString,16).toByteArray(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.xml.bind.DatatypeConverter; | |
public static String toHexString(byte[] array) { | |
return DatatypeConverter.printHexBinary(array); | |
} | |
public static byte[] toByteArray(String s) { | |
return DatatypeConverter.parseHexBinary(s); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Source:http://www.rgagnon.com/javadetails/java-0596.html | |
//the simple way | |
public static String getHexString(byte[] b) throws Exception { | |
String result = ""; | |
for (int i=0; i < b.length; i++) { | |
result += | |
Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 ); | |
} | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Using a Scanner makes it easy to search a text file for a string in Java. You can find the code HERE | |
import java.io.*; | |
import java.util.Scanner; | |
public class FileSearch { | |
public static void main(String[] args) { | |
// Testing only | |
File f = new File(args[0]); | |
String search = args[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AlertDialog ad = new AlertDialog.Builder(this).create(); | |
ad.setCancelable(false); // This blocks the 'BACK' button | |
ad.setMessage("Hello World"); | |
ad.setButton("OK", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
ad.show(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onDraw(Canvas canvas) { | |
super.onDraw(canvas); | |
canvas.restoreToCount(1); | |
canvas.clipRect(new Rect(0, 0, getWidth(), getHeight())); | |
canvas.drawCircle(x, y, 10, paint); | |
canvas.save(); | |
} | |
float x,y; | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LudoActivity extends Activity implements OnClickListener { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
requestWindowFeature(Window.FEATURE_NO_TITLE); | |
FrameLayout Game = new FrameLayout(this); | |
GameView Gameview = new GameView (this); | |
LinearLayout GameWidgets = new LinearLayout (this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ch.chrisii; | |
import java.util.List; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.graphics.Color; | |
import android.hardware.Sensor; | |
import android.hardware.SensorEvent; |
OlderNewer