http://stackoverflow.com/questions/409784/simplest-way-to-print-an-array-in-java
System.out.println(Arrays.toString(array));
This is my personal journal.
System.out.println(Arrays.toString(array));
char option;
int number;
do {
puts("Please enter your choice:");
fflush(stdout);
if (fgets(&option, 2, stdin) != NULL) {
if (option != '\n') {
scanf("%*[^\n]"); // get rid of the non-newline characters
scanf("%*c"); // get rid of the newline character
}
}
} while (!(sscanf(&option, "%d", &number) == 1 &&
number >= 1 && number <= 4));
char fileStr[20];
char *pointer = fileStr;
bool tooLong = false;
do {
printf("\nPlease input a file name: ");
fflush(stdout);
if (fgets(fileStr, sizeof fileStr, stdin) != NULL) {
tooLong = false;
if (*fileStr != '\n') {
// search for newline character
char *newline = strchr(fileStr, '\n');
if (newline != NULL) {
*newline = '\0'; /* overwrite trailing newline */
pointer = trimwhitespace(pointer); /* trim the line */
} else {
/* clear the stdin since user input too much */
tooLong = true;
scanf("%*[^\n]");
scanf("%*c");
}
}
}
} while (tooLong || *pointer == '\0' || *pointer == '\n');
printf("file name = \"%s\"\n", pointer);
function onkeypressed(e) {
var keyCode = (window.event) ? window.event.keyCode : e.which;
if (keyCode == 13) {
// do something
return true;
} else {
return false;
}
}
Pattern p = Pattern.compile(...);
Matcher m = p.matcher(inputString);
Listl = new ArrayList ();
for (int i = 0; m.find(i); i = m.end()) {
l.add(m.group(index)); // depends on your regular expression grouping
}
def onUnmappableCharacter(newAction: Action): this.type = { _onUnmappableCharacter = newAction ; this }
import java.nio.charset.CodingErrorAction.REPLACE
implicit def codec = Codec("big5").onUnmappableCharacter(REPLACE)
scala.io.Source.fromURL(...) // a big5 encoded page with unmappable
$ python -i
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
sys.stdout.buffer.write(line.decode("big5").encode())
import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout.buffer)
print(line.decode("big5")) # automatically using utf8 to output the unicode string