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
"pool-1-thread-194" prio=6 tid=0x0b57d000 nid=0x1710 runnable [0x0f4af000..0x0f4afa94]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
- locked <0x031a5488> (a java.io.BufferedInputStream)
at sun.net.www.MeteredStream.read(MeteredStream.java:116)
- locked <0x031efdc8> (a sun.net.www.http.KeepAliveStream)
at java.io.FilterInputStream.read(FilterInputStream.java:116)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2446)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
- locked <0x031efe48> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.read(BufferedReader.java:157)
- locked <0x031efe48> (a java.io.InputStreamReader)
at scala.io.BufferedSource$$anonfun$1$$anonfun$apply$1.apply(BufferedSource.scala:29)
at scala.io.BufferedSource$$anonfun$1$$anonfun$apply$1.apply(BufferedSource.scala:29)
at scala.io.Codec.wrap(Codec.scala:65)
at scala.io.BufferedSource$$anonfun$1.apply(BufferedSource.scala:29)
at scala.io.BufferedSource$$anonfun$1.apply(BufferedSource.scala:29)
at scala.collection.Iterator$$anon$11.next(Iterator.scala:146)
at scala.collection.Iterator$$anon$1.next(Iterator.scala:712)
at scala.collection.Iterator$$anon$1.head(Iterator.scala:699)
at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:374)
at scala.collection.Iterator$$anon$17.hasNext(Iterator.scala:319)
at scala.collection.Iterator$$anon$1.hasNext(Iterator.scala:706)
at scala.io.Source$LineIterator.getc(Source.scala:182)
at scala.io.Source$LineIterator.next(Source.scala:195)
at scala.io.Source$LineIterator.next(Source.scala:165)
at scala.io.Source.getLine(Source.scala:163)
import java.net.URL
import scala.io.Source
val timeout = 60000
val conn = (new URL(url)).openConnection()
conn.setConnectTimeout(timeout)
conn.setReadTimeout(timeout)
val inputStream = conn.getInputStream()
val src = Source.fromInputStream(inputStream,
Source.DefaultBufSize,
null,
() => inputStream.close())
for(my $i=0; $i < scalar(@ARGV); $i++) {
$ARGV[$i] = Encode::Byte::decode("cp950", $ARGV[$i]);
}
$data =~ s/(\P{IsASCII})/sprintf('%2x;',ord($1))/eg;
$response = Encode::decode_utf8($response);
binmode STDOUT, ":cp950";
-Dfile.encoding=UTF-8
PHP Fatal error: require_once() [function.require]: Failed opening required 'utilities.php' (include_path='/opt/ecloud/i686_Linux/php/lib/php') in /opt/ecloud/i686_Linux/apache/htdocs/accelerator/evalPhp.php(18) : eval()'d code on line 2
public void handle(String target,
HttpServletRequest request,
HttpServletResponse response,
int dispatch)
throws IOException,
ServletException {
// Obtain Jetty continuation
Continuation continuation = getContinuation(request, null);
// Create a custom callback and store it in each HttpServletRequest
// This callback is to wrap the continuation object for the other thread
// to call continuation.resume() for generating the response.
// "callback" should be a final static variable in production server.
Callback callback = (Callback) request.getAttribute("callback");
if (callback == null) {
callback = new Callback(continuation);
request.setAttribute("callback", callback);
}
// Synchronize on callback to prevent continuation.resume() from
// happening before continuation.suspend().
synchronized (callback) {
if (continuation.isNew()) {
// Dispatch the request to another area with different thread
// and of course, callback must be referenced later to call
// continuation.setObject() and continuation.resume() down the road.
}
// zero here for the simplicity
continuation.suspend(0);
}
// Up to this point, the continuation is resumed, and got the object ready
// for response.
PrintWriter out = null;
try {
out = response.getWriter();
Object obj = continuation.getObject();
// further processing the obj for the "out"
} finally {
if (out != null) {
out.close();
}
// Reset the continuation
continuation.reset();
continuation.setObject(null);
}
}