""
"import"
" "
"java"
""
"."
""
"net"
""
"."
""
"*"
""
";"
"\n"
"import"
" "
"java"
""
"."
""
"io"
""
"."
""
"*"
""
";"
"\n"
"import"
" "
"javax"
""
"."
""
"swing"
""
"."
""
"*"
""
";"
"\n"
"import"
" "
"java"
""
"."
""
"util"
""
"."
""
"regex"
""
"."
""
"*"
""
";"
"\n"
"import"
" "
"java"
""
"."
""
"util"
""
"."
""
"*"
""
";"
"\n"
"public"
" "
"class"
" "
"main"
" "
"{"
"\n "
"public"
" "
"static"
" "
"void"
" "
"main"
""
"("
""
"String"
""
"["
""
"]"
" "
"args"
""
")"
" "
"throws"
" "
"Exception"
" "
"{"
"\n"
"String"
" "
"prepost"
" "
"="
" "
"loadSnippet"
""
"("
""
"\"#1000288\""
""
")"
""
";"
"\n"
"saveMainJava"
""
"("
""
"prepost"
""
"."
""
"replace"
""
"("
""
"\"[...]\""
""
","
" "
"loadMainJava"
""
"("
""
")"
""
")"
""
")"
""
";"
"\n "
"}"
"\n\n "
"static"
" "
"String"
" "
"loadMainJava"
""
"("
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"return"
" "
"loadTextFile"
""
"("
""
"\"input/main.java\""
""
","
" "
"\"\""
""
")"
""
";"
"\n "
"}"
"\n\n "
"static"
" "
"void"
" "
"saveMainJava"
""
"("
""
"String"
" "
"s"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"saveTextFile"
""
"("
""
"\"output/main.java\""
""
","
" "
"s"
""
")"
""
";"
"\n "
"}"
"\n\n "
"static"
" "
"boolean"
" "
"preferCached"
" "
"="
" "
"false"
""
";"
"\n\n "
"public"
" "
"static"
" "
"String"
" "
"loadSnippet"
""
"("
""
"String"
" "
"snippetID"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"return"
" "
"loadSnippet"
""
"("
""
"parseSnippetID"
""
"("
""
"snippetID"
""
")"
""
","
" "
"preferCached"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"String"
" "
"loadSnippet"
""
"("
""
"String"
" "
"snippetID"
""
","
" "
"boolean"
" "
"preferCached"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"return"
" "
"loadSnippet"
""
"("
""
"parseSnippetID"
""
"("
""
"snippetID"
""
")"
""
","
" "
"preferCached"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"long"
" "
"parseSnippetID"
""
"("
""
"String"
" "
"snippetID"
""
")"
" "
"{"
"\n "
"return"
" "
"Long"
""
"."
""
"parseLong"
""
"("
""
"shortenSnippetID"
""
"("
""
"snippetID"
""
")"
""
")"
""
";"
"\n "
"}"
"\n\n "
"private"
" "
"static"
" "
"String"
" "
"shortenSnippetID"
""
"("
""
"String"
" "
"snippetID"
""
")"
" "
"{"
"\n "
"if"
" "
"("
""
"snippetID"
""
"."
""
"startsWith"
""
"("
""
"\"#\""
""
")"
""
")"
"\n "
"snippetID"
" "
"="
" "
"snippetID"
""
"."
""
"substring"
""
"("
""
"1"
""
")"
""
";"
"\n "
"String"
" "
"httpBlaBla"
" "
"="
" "
"\"http://tinybrain.de/\""
""
";"
"\n "
"if"
" "
"("
""
"snippetID"
""
"."
""
"startsWith"
""
"("
""
"httpBlaBla"
""
")"
""
")"
"\n "
"snippetID"
" "
"="
" "
"snippetID"
""
"."
""
"substring"
""
"("
""
"httpBlaBla"
""
"."
""
"length"
""
"("
""
")"
""
")"
""
";"
"\n "
"return"
" "
"snippetID"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"boolean"
" "
"isSnippetID"
""
"("
""
"String"
" "
"snippetID"
""
")"
" "
"{"
"\n "
"snippetID"
" "
"="
" "
"shortenSnippetID"
""
"("
""
"snippetID"
""
")"
""
";"
"\n "
"return"
" "
"isInteger"
""
"("
""
"snippetID"
""
")"
" "
"&"
""
"&"
" "
"Long"
""
"."
""
"parseLong"
""
"("
""
"snippetID"
""
")"
" "
"!"
""
"="
" "
"0"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"boolean"
" "
"isInteger"
""
"("
""
"String"
" "
"s"
""
")"
" "
"{"
"\n "
"return"
" "
"Pattern"
""
"."
""
"matches"
""
"("
""
"\"\\\\-?\\\\d+\""
""
","
" "
"s"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"String"
" "
"loadSnippet"
""
"("
""
"long"
" "
"snippetID"
""
","
" "
"boolean"
" "
"preferCached"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"if"
" "
"("
""
"preferCached"
""
")"
" "
"{"
"\n "
"initSnippetCache"
""
"("
""
")"
""
";"
"\n "
"String"
" "
"text"
" "
"="
" "
"DiskSnippetCache_get"
""
"("
""
"snippetID"
""
")"
""
";"
"\n "
"if"
" "
"("
""
"text"
" "
"!"
""
"="
" "
"null"
""
")"
"\n "
"return"
" "
"text"
""
";"
"\n "
"}"
"\n\n "
"String"
" "
"text"
""
";"
"\n "
"try"
" "
"{"
"\n "
"URL"
" "
"url"
" "
"="
" "
"new"
" "
"URL"
""
"("
""
"\"http://tinybrain.de:8080/getraw.php?id=\""
" "
"+"
" "
"snippetID"
""
")"
""
";"
"\n "
"text"
" "
"="
" "
"loadPage"
""
"("
""
"url"
""
")"
""
";"
"\n "
"}"
" "
"catch"
" "
"("
""
"FileNotFoundException"
" "
"e"
""
")"
" "
"{"
"\n "
"throw"
" "
"new"
" "
"IOException"
""
"("
""
"\"Snippet #\""
" "
"+"
" "
"snippetID"
" "
"+"
" "
"\" not found or not public\""
""
")"
""
";"
"\n "
"}"
"\n\n "
"try"
" "
"{"
"\n "
"initSnippetCache"
""
"("
""
")"
""
";"
"\n "
"DiskSnippetCache_put"
""
"("
""
"snippetID"
""
","
" "
"text"
""
")"
""
";"
"\n "
"}"
" "
"catch"
" "
"("
""
"IOException"
" "
"e"
""
")"
" "
"{"
"\n "
"System"
""
"."
""
"err"
""
"."
""
"println"
""
"("
""
"\"Minor warning: Couldn't save snippet to cache (\""
" "
"+"
" "
"DiskSnippetCache_getDir"
""
"("
""
")"
" "
"+"
" "
"\")\""
""
")"
""
";"
"\n "
"}"
"\n\n "
"return"
" "
"text"
""
";"
"\n "
"}"
"\n\n "
"private"
" "
"static"
" "
"String"
" "
"loadPage"
""
"("
""
"URL"
" "
"url"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"System"
""
"."
""
"out"
""
"."
""
"println"
""
"("
""
"\"Loading: \""
" "
"+"
" "
"url"
""
"."
""
"toExternalForm"
""
"("
""
")"
""
")"
""
";"
"\n "
"URLConnection"
" "
"con"
" "
"="
" "
"url"
""
"."
""
"openConnection"
""
"("
""
")"
""
";"
"\n "
"return"
" "
"loadPage"
""
"("
""
"con"
""
","
" "
"url"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"String"
" "
"loadPage"
""
"("
""
"URLConnection"
" "
"con"
""
","
" "
"URL"
" "
"url"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"String"
" "
"contentType"
" "
"="
" "
"con"
""
"."
""
"getContentType"
""
"("
""
")"
""
";"
"\n "
"if"
" "
"("
""
"contentType"
" "
"="
""
"="
" "
"null"
""
")"
"\n "
"throw"
" "
"new"
" "
"IOException"
""
"("
""
"\"Page could not be read: \""
" "
"+"
" "
"url"
""
")"
""
";"
"\n //Log.info(\"Content-Type: \" + contentType);\n "
"String"
" "
"charset"
" "
"="
" "
"guessCharset"
""
"("
""
"contentType"
""
")"
""
";"
"\n "
"Reader"
" "
"r"
" "
"="
" "
"new"
" "
"InputStreamReader"
""
"("
""
"con"
""
"."
""
"getInputStream"
""
"("
""
")"
""
","
" "
"charset"
""
")"
""
";"
"\n "
"StringBuilder"
" "
"buf"
" "
"="
" "
"new"
" "
"StringBuilder"
""
"("
""
")"
""
";"
"\n "
"while"
" "
"("
""
"true"
""
")"
" "
"{"
"\n "
"int"
" "
"ch"
" "
"="
" "
"r"
""
"."
""
"read"
""
"("
""
")"
""
";"
"\n "
"if"
" "
"("
""
"ch"
" "
"<"
" "
"0"
""
")"
"\n "
"break"
""
";"
"\n //Log.info(\"Chars read: \" + buf.length());\n "
"buf"
""
"."
""
"append"
""
"("
""
"("
""
"char"
""
")"
" "
"ch"
""
")"
""
";"
"\n "
"}"
"\n "
"return"
" "
"buf"
""
"."
""
"toString"
""
"("
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"String"
" "
"guessCharset"
""
"("
""
"String"
" "
"contentType"
""
")"
" "
"{"
"\n "
"Pattern"
" "
"p"
" "
"="
" "
"Pattern"
""
"."
""
"compile"
""
"("
""
"\"text/html;\\\\s+charset=([^\\\\s]+)\\\\s*\""
""
")"
""
";"
"\n "
"Matcher"
" "
"m"
" "
"="
" "
"p"
""
"."
""
"matcher"
""
"("
""
"contentType"
""
")"
""
";"
"\n /* If Content-Type doesn't match this pre-conception, choose default and hope for the best. */\n "
"return"
" "
"m"
""
"."
""
"matches"
""
"("
""
")"
" "
"?"
" "
"m"
""
"."
""
"group"
""
"("
""
"1"
""
")"
" "
":"
" "
"\"ISO-8859-1\""
""
";"
"\n "
"}"
"\n\n "
"static"
" "
"File"
" "
"DiskSnippetCache_dir"
""
";"
"\n\n "
"public"
" "
"static"
" "
"void"
" "
"initDiskSnippetCache"
""
"("
""
"File"
" "
"dir"
""
")"
" "
"{"
"\n "
"DiskSnippetCache_dir"
" "
"="
" "
"dir"
""
";"
"\n "
"dir"
""
"."
""
"mkdirs"
""
"("
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"synchronized"
" "
"String"
" "
"DiskSnippetCache_get"
""
"("
""
"long"
" "
"snippetID"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"return"
" "
"loadTextFile"
""
"("
""
"DiskSnippetCache_getFile"
""
"("
""
"snippetID"
""
")"
""
"."
""
"getPath"
""
"("
""
")"
""
","
" "
"null"
""
")"
""
";"
"\n "
"}"
"\n\n "
"private"
" "
"static"
" "
"File"
" "
"DiskSnippetCache_getFile"
""
"("
""
"long"
" "
"snippetID"
""
")"
" "
"{"
"\n "
"return"
" "
"new"
" "
"File"
""
"("
""
"DiskSnippetCache_dir"
""
","
" "
"\"\""
" "
"+"
" "
"snippetID"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"synchronized"
" "
"void"
" "
"DiskSnippetCache_put"
""
"("
""
"long"
" "
"snippetID"
""
","
" "
"String"
" "
"snippet"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"saveTextFile"
""
"("
""
"DiskSnippetCache_getFile"
""
"("
""
"snippetID"
""
")"
""
"."
""
"getPath"
""
"("
""
")"
""
","
" "
"snippet"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"File"
" "
"DiskSnippetCache_getDir"
""
"("
""
")"
" "
"{"
"\n "
"return"
" "
"DiskSnippetCache_dir"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"void"
" "
"initSnippetCache"
""
"("
""
")"
" "
"{"
"\n "
"if"
" "
"("
""
"DiskSnippetCache_dir"
" "
"="
""
"="
" "
"null"
""
")"
"\n "
"initDiskSnippetCache"
""
"("
""
"new"
" "
"File"
""
"("
""
"System"
""
"."
""
"getProperty"
""
"("
""
"\"user.home\""
""
")"
""
","
" "
"\".tinybrain/snippet-cache\""
""
")"
""
")"
""
";"
"\n "
"}"
"\n \n\n /** writes safely (to temp file, then rename) */\n "
"public"
" "
"static"
" "
"void"
" "
"saveTextFile"
""
"("
""
"String"
" "
"fileName"
""
","
" "
"String"
" "
"contents"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"File"
" "
"file"
" "
"="
" "
"new"
" "
"File"
""
"("
""
"fileName"
""
")"
""
";"
"\n "
"File"
" "
"parentFile"
" "
"="
" "
"file"
""
"."
""
"getParentFile"
""
"("
""
")"
""
";"
"\n "
"if"
" "
"("
""
"parentFile"
" "
"!"
""
"="
" "
"null"
""
")"
"\n "
"parentFile"
""
"."
""
"mkdirs"
""
"("
""
")"
""
";"
"\n "
"String"
" "
"tempFileName"
" "
"="
" "
"fileName"
" "
"+"
" "
"\"_temp\""
""
";"
"\n "
"FileOutputStream"
" "
"fileOutputStream"
" "
"="
" "
"new"
" "
"FileOutputStream"
""
"("
""
"tempFileName"
""
")"
""
";"
"\n "
"OutputStreamWriter"
" "
"outputStreamWriter"
" "
"="
" "
"new"
" "
"OutputStreamWriter"
""
"("
""
"fileOutputStream"
""
","
" "
"\"UTF-8\""
""
")"
""
";"
"\n "
"PrintWriter"
" "
"printWriter"
" "
"="
" "
"new"
" "
"PrintWriter"
""
"("
""
"outputStreamWriter"
""
")"
""
";"
"\n "
"printWriter"
""
"."
""
"print"
""
"("
""
"contents"
""
")"
""
";"
"\n "
"printWriter"
""
"."
""
"close"
""
"("
""
")"
""
";"
"\n "
"if"
" "
"("
""
"file"
""
"."
""
"exists"
""
"("
""
")"
" "
"&"
""
"&"
" "
"!"
""
"file"
""
"."
""
"delete"
""
"("
""
")"
""
")"
"\n "
"throw"
" "
"new"
" "
"IOException"
""
"("
""
"\"Can't delete \""
" "
"+"
" "
"fileName"
""
")"
""
";"
"\n\n "
"if"
" "
"("
""
"!"
""
"new"
" "
"File"
""
"("
""
"tempFileName"
""
")"
""
"."
""
"renameTo"
""
"("
""
"file"
""
")"
""
")"
"\n "
"throw"
" "
"new"
" "
"IOException"
""
"("
""
"\"Can't rename \""
" "
"+"
" "
"tempFileName"
" "
"+"
" "
"\" to \""
" "
"+"
" "
"fileName"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"String"
" "
"loadTextFile"
""
"("
""
"String"
" "
"fileName"
""
","
" "
"String"
" "
"defaultContents"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"if"
" "
"("
""
"!"
""
"new"
" "
"File"
""
"("
""
"fileName"
""
")"
""
"."
""
"exists"
""
"("
""
")"
""
")"
"\n "
"return"
" "
"defaultContents"
""
";"
"\n\n "
"FileInputStream"
" "
"fileInputStream"
" "
"="
" "
"new"
" "
"FileInputStream"
""
"("
""
"fileName"
""
")"
""
";"
"\n "
"InputStreamReader"
" "
"inputStreamReader"
" "
"="
" "
"new"
" "
"InputStreamReader"
""
"("
""
"fileInputStream"
""
","
" "
"\"UTF-8\""
""
")"
""
";"
"\n "
"return"
" "
"loadTextFile"
""
"("
""
"inputStreamReader"
""
")"
""
";"
"\n "
"}"
"\n\n "
"public"
" "
"static"
" "
"String"
" "
"loadTextFile"
""
"("
""
"Reader"
" "
"reader"
""
")"
" "
"throws"
" "
"IOException"
" "
"{"
"\n "
"StringBuilder"
" "
"builder"
" "
"="
" "
"new"
" "
"StringBuilder"
""
"("
""
")"
""
";"
"\n "
"try"
" "
"{"
"\n "
"BufferedReader"
" "
"bufferedReader"
" "
"="
" "
"new"
" "
"BufferedReader"
""
"("
""
"reader"
""
")"
""
";"
"\n "
"String"
" "
"line"
""
";"
"\n "
"while"
" "
"("
""
"("
""
"line"
" "
"="
" "
"bufferedReader"
""
"."
""
"readLine"
""
"("
""
")"
""
")"
" "
"!"
""
"="
" "
"null"
""
")"
"\n "
"builder"
""
"."
""
"append"
""
"("
""
"line"
""
")"
""
"."
""
"append"
""
"("
""
"'\\n'"
""
")"
""
";"
"\n "
"}"
" "
"finally"
" "
"{"
"\n "
"reader"
""
"."
""
"close"
""
"("
""
")"
""
";"
"\n "
"}"
"\n "
"return"
" "
"builder"
""
"."
""
"length"
""
"("
""
")"
" "
"="
""
"="
" "
"0"
" "
"?"
" "
"\"\""
" "
":"
" "
"builder"
""
"."
""
"substring"
""
"("
""
"0"
""
","
" "
"builder"
""
"."
""
"length"
""
"("
""
")"
""
"-"
""
"1"
""
")"
""
";"
"\n "
"}"
"\n"
"}"
""Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #2000397 |
| Snippet name: | Application of #651 on #634 |
| Eternal ID of this version: | #2000397/1 |
| Text MD5: | ffc7831055ab6baf5ea1fbe5739367d3 |
| Author: | someone |
| Category: | |
| Type: | New Tinybrain snippet |
| Gummipassword: | apply translator 651 |
| Uploaded from IP: | 84.201.25.107 |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-06-27 20:39:37 |
| Source code size: | 12738 bytes / 2147 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 741 / 414 |
| Referenced in: | #652 - Find main class (from CNC Tokenization) #3000189 - Answer for stefanreich(>> t bla) #3000382 - Answer for ferdie (>> t = 1, f = 0) #3000383 - Answer for funkoverflow (>> t=1, f=0 okay) |