Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

2147
LINES

< > BotCompany Repo | #2000397 // Application of #651 on #634

New Tinybrain snippet

1  
""
2  
"import"
3  
" "
4  
"java"
5  
""
6  
"."
7  
""
8  
"net"
9  
""
10  
"."
11  
""
12  
"*"
13  
""
14  
";"
15  
"\n"
16  
"import"
17  
" "
18  
"java"
19  
""
20  
"."
21  
""
22  
"io"
23  
""
24  
"."
25  
""
26  
"*"
27  
""
28  
";"
29  
"\n"
30  
"import"
31  
" "
32  
"javax"
33  
""
34  
"."
35  
""
36  
"swing"
37  
""
38  
"."
39  
""
40  
"*"
41  
""
42  
";"
43  
"\n"
44  
"import"
45  
" "
46  
"java"
47  
""
48  
"."
49  
""
50  
"util"
51  
""
52  
"."
53  
""
54  
"regex"
55  
""
56  
"."
57  
""
58  
"*"
59  
""
60  
";"
61  
"\n"
62  
"import"
63  
" "
64  
"java"
65  
""
66  
"."
67  
""
68  
"util"
69  
""
70  
"."
71  
""
72  
"*"
73  
""
74  
";"
75  
"\n"
76  
"public"
77  
" "
78  
"class"
79  
" "
80  
"main"
81  
" "
82  
"{"
83  
"\n  "
84  
"public"
85  
" "
86  
"static"
87  
" "
88  
"void"
89  
" "
90  
"main"
91  
""
92  
"("
93  
""
94  
"String"
95  
""
96  
"["
97  
""
98  
"]"
99  
" "
100  
"args"
101  
""
102  
")"
103  
" "
104  
"throws"
105  
" "
106  
"Exception"
107  
" "
108  
"{"
109  
"\n"
110  
"String"
111  
" "
112  
"prepost"
113  
" "
114  
"="
115  
" "
116  
"loadSnippet"
117  
""
118  
"("
119  
""
120  
"\"#1000288\""
121  
""
122  
")"
123  
""
124  
";"
125  
"\n"
126  
"saveMainJava"
127  
""
128  
"("
129  
""
130  
"prepost"
131  
""
132  
"."
133  
""
134  
"replace"
135  
""
136  
"("
137  
""
138  
"\"[...]\""
139  
""
140  
","
141  
" "
142  
"loadMainJava"
143  
""
144  
"("
145  
""
146  
")"
147  
""
148  
")"
149  
""
150  
")"
151  
""
152  
";"
153  
"\n  "
154  
"}"
155  
"\n\n  "
156  
"static"
157  
" "
158  
"String"
159  
" "
160  
"loadMainJava"
161  
""
162  
"("
163  
""
164  
")"
165  
" "
166  
"throws"
167  
" "
168  
"IOException"
169  
" "
170  
"{"
171  
"\n    "
172  
"return"
173  
" "
174  
"loadTextFile"
175  
""
176  
"("
177  
""
178  
"\"input/main.java\""
179  
""
180  
","
181  
" "
182  
"\"\""
183  
""
184  
")"
185  
""
186  
";"
187  
"\n  "
188  
"}"
189  
"\n\n  "
190  
"static"
191  
" "
192  
"void"
193  
" "
194  
"saveMainJava"
195  
""
196  
"("
197  
""
198  
"String"
199  
" "
200  
"s"
201  
""
202  
")"
203  
" "
204  
"throws"
205  
" "
206  
"IOException"
207  
" "
208  
"{"
209  
"\n    "
210  
"saveTextFile"
211  
""
212  
"("
213  
""
214  
"\"output/main.java\""
215  
""
216  
","
217  
" "
218  
"s"
219  
""
220  
")"
221  
""
222  
";"
223  
"\n  "
224  
"}"
225  
"\n\n  "
226  
"static"
227  
" "
228  
"boolean"
229  
" "
230  
"preferCached"
231  
" "
232  
"="
233  
" "
234  
"false"
235  
""
236  
";"
237  
"\n\n  "
238  
"public"
239  
" "
240  
"static"
241  
" "
242  
"String"
243  
" "
244  
"loadSnippet"
245  
""
246  
"("
247  
""
248  
"String"
249  
" "
250  
"snippetID"
251  
""
252  
")"
253  
" "
254  
"throws"
255  
" "
256  
"IOException"
257  
" "
258  
"{"
259  
"\n    "
260  
"return"
261  
" "
262  
"loadSnippet"
263  
""
264  
"("
265  
""
266  
"parseSnippetID"
267  
""
268  
"("
269  
""
270  
"snippetID"
271  
""
272  
")"
273  
""
274  
","
275  
" "
276  
"preferCached"
277  
""
278  
")"
279  
""
280  
";"
281  
"\n  "
282  
"}"
283  
"\n\n  "
284  
"public"
285  
" "
286  
"static"
287  
" "
288  
"String"
289  
" "
290  
"loadSnippet"
291  
""
292  
"("
293  
""
294  
"String"
295  
" "
296  
"snippetID"
297  
""
298  
","
299  
" "
300  
"boolean"
301  
" "
302  
"preferCached"
303  
""
304  
")"
305  
" "
306  
"throws"
307  
" "
308  
"IOException"
309  
" "
310  
"{"
311  
"\n    "
312  
"return"
313  
" "
314  
"loadSnippet"
315  
""
316  
"("
317  
""
318  
"parseSnippetID"
319  
""
320  
"("
321  
""
322  
"snippetID"
323  
""
324  
")"
325  
""
326  
","
327  
" "
328  
"preferCached"
329  
""
330  
")"
331  
""
332  
";"
333  
"\n  "
334  
"}"
335  
"\n\n  "
336  
"public"
337  
" "
338  
"static"
339  
" "
340  
"long"
341  
" "
342  
"parseSnippetID"
343  
""
344  
"("
345  
""
346  
"String"
347  
" "
348  
"snippetID"
349  
""
350  
")"
351  
" "
352  
"{"
353  
"\n    "
354  
"return"
355  
" "
356  
"Long"
357  
""
358  
"."
359  
""
360  
"parseLong"
361  
""
362  
"("
363  
""
364  
"shortenSnippetID"
365  
""
366  
"("
367  
""
368  
"snippetID"
369  
""
370  
")"
371  
""
372  
")"
373  
""
374  
";"
375  
"\n  "
376  
"}"
377  
"\n\n  "
378  
"private"
379  
" "
380  
"static"
381  
" "
382  
"String"
383  
" "
384  
"shortenSnippetID"
385  
""
386  
"("
387  
""
388  
"String"
389  
" "
390  
"snippetID"
391  
""
392  
")"
393  
" "
394  
"{"
395  
"\n    "
396  
"if"
397  
" "
398  
"("
399  
""
400  
"snippetID"
401  
""
402  
"."
403  
""
404  
"startsWith"
405  
""
406  
"("
407  
""
408  
"\"#\""
409  
""
410  
")"
411  
""
412  
")"
413  
"\n      "
414  
"snippetID"
415  
" "
416  
"="
417  
" "
418  
"snippetID"
419  
""
420  
"."
421  
""
422  
"substring"
423  
""
424  
"("
425  
""
426  
"1"
427  
""
428  
")"
429  
""
430  
";"
431  
"\n    "
432  
"String"
433  
" "
434  
"httpBlaBla"
435  
" "
436  
"="
437  
" "
438  
"\"http://tinybrain.de/\""
439  
""
440  
";"
441  
"\n    "
442  
"if"
443  
" "
444  
"("
445  
""
446  
"snippetID"
447  
""
448  
"."
449  
""
450  
"startsWith"
451  
""
452  
"("
453  
""
454  
"httpBlaBla"
455  
""
456  
")"
457  
""
458  
")"
459  
"\n      "
460  
"snippetID"
461  
" "
462  
"="
463  
" "
464  
"snippetID"
465  
""
466  
"."
467  
""
468  
"substring"
469  
""
470  
"("
471  
""
472  
"httpBlaBla"
473  
""
474  
"."
475  
""
476  
"length"
477  
""
478  
"("
479  
""
480  
")"
481  
""
482  
")"
483  
""
484  
";"
485  
"\n    "
486  
"return"
487  
" "
488  
"snippetID"
489  
""
490  
";"
491  
"\n  "
492  
"}"
493  
"\n\n  "
494  
"public"
495  
" "
496  
"static"
497  
" "
498  
"boolean"
499  
" "
500  
"isSnippetID"
501  
""
502  
"("
503  
""
504  
"String"
505  
" "
506  
"snippetID"
507  
""
508  
")"
509  
" "
510  
"{"
511  
"\n    "
512  
"snippetID"
513  
" "
514  
"="
515  
" "
516  
"shortenSnippetID"
517  
""
518  
"("
519  
""
520  
"snippetID"
521  
""
522  
")"
523  
""
524  
";"
525  
"\n    "
526  
"return"
527  
" "
528  
"isInteger"
529  
""
530  
"("
531  
""
532  
"snippetID"
533  
""
534  
")"
535  
" "
536  
"&"
537  
""
538  
"&"
539  
" "
540  
"Long"
541  
""
542  
"."
543  
""
544  
"parseLong"
545  
""
546  
"("
547  
""
548  
"snippetID"
549  
""
550  
")"
551  
" "
552  
"!"
553  
""
554  
"="
555  
" "
556  
"0"
557  
""
558  
";"
559  
"\n  "
560  
"}"
561  
"\n\n  "
562  
"public"
563  
" "
564  
"static"
565  
" "
566  
"boolean"
567  
" "
568  
"isInteger"
569  
""
570  
"("
571  
""
572  
"String"
573  
" "
574  
"s"
575  
""
576  
")"
577  
" "
578  
"{"
579  
"\n    "
580  
"return"
581  
" "
582  
"Pattern"
583  
""
584  
"."
585  
""
586  
"matches"
587  
""
588  
"("
589  
""
590  
"\"\\\\-?\\\\d+\""
591  
""
592  
","
593  
" "
594  
"s"
595  
""
596  
")"
597  
""
598  
";"
599  
"\n  "
600  
"}"
601  
"\n\n  "
602  
"public"
603  
" "
604  
"static"
605  
" "
606  
"String"
607  
" "
608  
"loadSnippet"
609  
""
610  
"("
611  
""
612  
"long"
613  
" "
614  
"snippetID"
615  
""
616  
","
617  
" "
618  
"boolean"
619  
" "
620  
"preferCached"
621  
""
622  
")"
623  
" "
624  
"throws"
625  
" "
626  
"IOException"
627  
" "
628  
"{"
629  
"\n    "
630  
"if"
631  
" "
632  
"("
633  
""
634  
"preferCached"
635  
""
636  
")"
637  
" "
638  
"{"
639  
"\n      "
640  
"initSnippetCache"
641  
""
642  
"("
643  
""
644  
")"
645  
""
646  
";"
647  
"\n      "
648  
"String"
649  
" "
650  
"text"
651  
" "
652  
"="
653  
" "
654  
"DiskSnippetCache_get"
655  
""
656  
"("
657  
""
658  
"snippetID"
659  
""
660  
")"
661  
""
662  
";"
663  
"\n      "
664  
"if"
665  
" "
666  
"("
667  
""
668  
"text"
669  
" "
670  
"!"
671  
""
672  
"="
673  
" "
674  
"null"
675  
""
676  
")"
677  
"\n        "
678  
"return"
679  
" "
680  
"text"
681  
""
682  
";"
683  
"\n    "
684  
"}"
685  
"\n\n    "
686  
"String"
687  
" "
688  
"text"
689  
""
690  
";"
691  
"\n    "
692  
"try"
693  
" "
694  
"{"
695  
"\n      "
696  
"URL"
697  
" "
698  
"url"
699  
" "
700  
"="
701  
" "
702  
"new"
703  
" "
704  
"URL"
705  
""
706  
"("
707  
""
708  
"\"http://tinybrain.de:8080/getraw.php?id=\""
709  
" "
710  
"+"
711  
" "
712  
"snippetID"
713  
""
714  
")"
715  
""
716  
";"
717  
"\n      "
718  
"text"
719  
" "
720  
"="
721  
" "
722  
"loadPage"
723  
""
724  
"("
725  
""
726  
"url"
727  
""
728  
")"
729  
""
730  
";"
731  
"\n    "
732  
"}"
733  
" "
734  
"catch"
735  
" "
736  
"("
737  
""
738  
"FileNotFoundException"
739  
" "
740  
"e"
741  
""
742  
")"
743  
" "
744  
"{"
745  
"\n      "
746  
"throw"
747  
" "
748  
"new"
749  
" "
750  
"IOException"
751  
""
752  
"("
753  
""
754  
"\"Snippet #\""
755  
" "
756  
"+"
757  
" "
758  
"snippetID"
759  
" "
760  
"+"
761  
" "
762  
"\" not found or not public\""
763  
""
764  
")"
765  
""
766  
";"
767  
"\n    "
768  
"}"
769  
"\n\n    "
770  
"try"
771  
" "
772  
"{"
773  
"\n      "
774  
"initSnippetCache"
775  
""
776  
"("
777  
""
778  
")"
779  
""
780  
";"
781  
"\n      "
782  
"DiskSnippetCache_put"
783  
""
784  
"("
785  
""
786  
"snippetID"
787  
""
788  
","
789  
" "
790  
"text"
791  
""
792  
")"
793  
""
794  
";"
795  
"\n    "
796  
"}"
797  
" "
798  
"catch"
799  
" "
800  
"("
801  
""
802  
"IOException"
803  
" "
804  
"e"
805  
""
806  
")"
807  
" "
808  
"{"
809  
"\n      "
810  
"System"
811  
""
812  
"."
813  
""
814  
"err"
815  
""
816  
"."
817  
""
818  
"println"
819  
""
820  
"("
821  
""
822  
"\"Minor warning: Couldn't save snippet to cache (\""
823  
"  "
824  
"+"
825  
" "
826  
"DiskSnippetCache_getDir"
827  
""
828  
"("
829  
""
830  
")"
831  
" "
832  
"+"
833  
" "
834  
"\")\""
835  
""
836  
")"
837  
""
838  
";"
839  
"\n    "
840  
"}"
841  
"\n\n    "
842  
"return"
843  
" "
844  
"text"
845  
""
846  
";"
847  
"\n  "
848  
"}"
849  
"\n\n  "
850  
"private"
851  
" "
852  
"static"
853  
" "
854  
"String"
855  
" "
856  
"loadPage"
857  
""
858  
"("
859  
""
860  
"URL"
861  
" "
862  
"url"
863  
""
864  
")"
865  
" "
866  
"throws"
867  
" "
868  
"IOException"
869  
" "
870  
"{"
871  
"\n    "
872  
"System"
873  
""
874  
"."
875  
""
876  
"out"
877  
""
878  
"."
879  
""
880  
"println"
881  
""
882  
"("
883  
""
884  
"\"Loading: \""
885  
" "
886  
"+"
887  
" "
888  
"url"
889  
""
890  
"."
891  
""
892  
"toExternalForm"
893  
""
894  
"("
895  
""
896  
")"
897  
""
898  
")"
899  
""
900  
";"
901  
"\n    "
902  
"URLConnection"
903  
" "
904  
"con"
905  
" "
906  
"="
907  
" "
908  
"url"
909  
""
910  
"."
911  
""
912  
"openConnection"
913  
""
914  
"("
915  
""
916  
")"
917  
""
918  
";"
919  
"\n    "
920  
"return"
921  
" "
922  
"loadPage"
923  
""
924  
"("
925  
""
926  
"con"
927  
""
928  
","
929  
" "
930  
"url"
931  
""
932  
")"
933  
""
934  
";"
935  
"\n  "
936  
"}"
937  
"\n\n  "
938  
"public"
939  
" "
940  
"static"
941  
" "
942  
"String"
943  
" "
944  
"loadPage"
945  
""
946  
"("
947  
""
948  
"URLConnection"
949  
" "
950  
"con"
951  
""
952  
","
953  
" "
954  
"URL"
955  
" "
956  
"url"
957  
""
958  
")"
959  
" "
960  
"throws"
961  
" "
962  
"IOException"
963  
" "
964  
"{"
965  
"\n    "
966  
"String"
967  
" "
968  
"contentType"
969  
" "
970  
"="
971  
" "
972  
"con"
973  
""
974  
"."
975  
""
976  
"getContentType"
977  
""
978  
"("
979  
""
980  
")"
981  
""
982  
";"
983  
"\n    "
984  
"if"
985  
" "
986  
"("
987  
""
988  
"contentType"
989  
" "
990  
"="
991  
""
992  
"="
993  
" "
994  
"null"
995  
""
996  
")"
997  
"\n      "
998  
"throw"
999  
" "
1000  
"new"
1001  
" "
1002  
"IOException"
1003  
""
1004  
"("
1005  
""
1006  
"\"Page could not be read: \""
1007  
" "
1008  
"+"
1009  
" "
1010  
"url"
1011  
""
1012  
")"
1013  
""
1014  
";"
1015  
"\n    //Log.info(\"Content-Type: \" + contentType);\n    "
1016  
"String"
1017  
" "
1018  
"charset"
1019  
" "
1020  
"="
1021  
" "
1022  
"guessCharset"
1023  
""
1024  
"("
1025  
""
1026  
"contentType"
1027  
""
1028  
")"
1029  
""
1030  
";"
1031  
"\n    "
1032  
"Reader"
1033  
" "
1034  
"r"
1035  
" "
1036  
"="
1037  
" "
1038  
"new"
1039  
" "
1040  
"InputStreamReader"
1041  
""
1042  
"("
1043  
""
1044  
"con"
1045  
""
1046  
"."
1047  
""
1048  
"getInputStream"
1049  
""
1050  
"("
1051  
""
1052  
")"
1053  
""
1054  
","
1055  
" "
1056  
"charset"
1057  
""
1058  
")"
1059  
""
1060  
";"
1061  
"\n    "
1062  
"StringBuilder"
1063  
" "
1064  
"buf"
1065  
" "
1066  
"="
1067  
" "
1068  
"new"
1069  
" "
1070  
"StringBuilder"
1071  
""
1072  
"("
1073  
""
1074  
")"
1075  
""
1076  
";"
1077  
"\n    "
1078  
"while"
1079  
" "
1080  
"("
1081  
""
1082  
"true"
1083  
""
1084  
")"
1085  
" "
1086  
"{"
1087  
"\n      "
1088  
"int"
1089  
" "
1090  
"ch"
1091  
" "
1092  
"="
1093  
" "
1094  
"r"
1095  
""
1096  
"."
1097  
""
1098  
"read"
1099  
""
1100  
"("
1101  
""
1102  
")"
1103  
""
1104  
";"
1105  
"\n      "
1106  
"if"
1107  
" "
1108  
"("
1109  
""
1110  
"ch"
1111  
" "
1112  
"<"
1113  
" "
1114  
"0"
1115  
""
1116  
")"
1117  
"\n        "
1118  
"break"
1119  
""
1120  
";"
1121  
"\n      //Log.info(\"Chars read: \" + buf.length());\n      "
1122  
"buf"
1123  
""
1124  
"."
1125  
""
1126  
"append"
1127  
""
1128  
"("
1129  
""
1130  
"("
1131  
""
1132  
"char"
1133  
""
1134  
")"
1135  
" "
1136  
"ch"
1137  
""
1138  
")"
1139  
""
1140  
";"
1141  
"\n    "
1142  
"}"
1143  
"\n    "
1144  
"return"
1145  
" "
1146  
"buf"
1147  
""
1148  
"."
1149  
""
1150  
"toString"
1151  
""
1152  
"("
1153  
""
1154  
")"
1155  
""
1156  
";"
1157  
"\n  "
1158  
"}"
1159  
"\n\n  "
1160  
"public"
1161  
" "
1162  
"static"
1163  
" "
1164  
"String"
1165  
" "
1166  
"guessCharset"
1167  
""
1168  
"("
1169  
""
1170  
"String"
1171  
" "
1172  
"contentType"
1173  
""
1174  
")"
1175  
" "
1176  
"{"
1177  
"\n    "
1178  
"Pattern"
1179  
" "
1180  
"p"
1181  
" "
1182  
"="
1183  
" "
1184  
"Pattern"
1185  
""
1186  
"."
1187  
""
1188  
"compile"
1189  
""
1190  
"("
1191  
""
1192  
"\"text/html;\\\\s+charset=([^\\\\s]+)\\\\s*\""
1193  
""
1194  
")"
1195  
""
1196  
";"
1197  
"\n    "
1198  
"Matcher"
1199  
" "
1200  
"m"
1201  
" "
1202  
"="
1203  
" "
1204  
"p"
1205  
""
1206  
"."
1207  
""
1208  
"matcher"
1209  
""
1210  
"("
1211  
""
1212  
"contentType"
1213  
""
1214  
")"
1215  
""
1216  
";"
1217  
"\n    /* If Content-Type doesn't match this pre-conception, choose default and hope for the best. */\n    "
1218  
"return"
1219  
" "
1220  
"m"
1221  
""
1222  
"."
1223  
""
1224  
"matches"
1225  
""
1226  
"("
1227  
""
1228  
")"
1229  
" "
1230  
"?"
1231  
" "
1232  
"m"
1233  
""
1234  
"."
1235  
""
1236  
"group"
1237  
""
1238  
"("
1239  
""
1240  
"1"
1241  
""
1242  
")"
1243  
" "
1244  
":"
1245  
" "
1246  
"\"ISO-8859-1\""
1247  
""
1248  
";"
1249  
"\n  "
1250  
"}"
1251  
"\n\n  "
1252  
"static"
1253  
" "
1254  
"File"
1255  
" "
1256  
"DiskSnippetCache_dir"
1257  
""
1258  
";"
1259  
"\n\n  "
1260  
"public"
1261  
" "
1262  
"static"
1263  
" "
1264  
"void"
1265  
" "
1266  
"initDiskSnippetCache"
1267  
""
1268  
"("
1269  
""
1270  
"File"
1271  
" "
1272  
"dir"
1273  
""
1274  
")"
1275  
" "
1276  
"{"
1277  
"\n    "
1278  
"DiskSnippetCache_dir"
1279  
" "
1280  
"="
1281  
" "
1282  
"dir"
1283  
""
1284  
";"
1285  
"\n    "
1286  
"dir"
1287  
""
1288  
"."
1289  
""
1290  
"mkdirs"
1291  
""
1292  
"("
1293  
""
1294  
")"
1295  
""
1296  
";"
1297  
"\n  "
1298  
"}"
1299  
"\n\n  "
1300  
"public"
1301  
" "
1302  
"static"
1303  
" "
1304  
"synchronized"
1305  
" "
1306  
"String"
1307  
" "
1308  
"DiskSnippetCache_get"
1309  
""
1310  
"("
1311  
""
1312  
"long"
1313  
" "
1314  
"snippetID"
1315  
""
1316  
")"
1317  
" "
1318  
"throws"
1319  
" "
1320  
"IOException"
1321  
" "
1322  
"{"
1323  
"\n    "
1324  
"return"
1325  
" "
1326  
"loadTextFile"
1327  
""
1328  
"("
1329  
""
1330  
"DiskSnippetCache_getFile"
1331  
""
1332  
"("
1333  
""
1334  
"snippetID"
1335  
""
1336  
")"
1337  
""
1338  
"."
1339  
""
1340  
"getPath"
1341  
""
1342  
"("
1343  
""
1344  
")"
1345  
""
1346  
","
1347  
" "
1348  
"null"
1349  
""
1350  
")"
1351  
""
1352  
";"
1353  
"\n  "
1354  
"}"
1355  
"\n\n  "
1356  
"private"
1357  
" "
1358  
"static"
1359  
" "
1360  
"File"
1361  
" "
1362  
"DiskSnippetCache_getFile"
1363  
""
1364  
"("
1365  
""
1366  
"long"
1367  
" "
1368  
"snippetID"
1369  
""
1370  
")"
1371  
" "
1372  
"{"
1373  
"\n    "
1374  
"return"
1375  
" "
1376  
"new"
1377  
" "
1378  
"File"
1379  
""
1380  
"("
1381  
""
1382  
"DiskSnippetCache_dir"
1383  
""
1384  
","
1385  
" "
1386  
"\"\""
1387  
" "
1388  
"+"
1389  
" "
1390  
"snippetID"
1391  
""
1392  
")"
1393  
""
1394  
";"
1395  
"\n  "
1396  
"}"
1397  
"\n\n  "
1398  
"public"
1399  
" "
1400  
"static"
1401  
" "
1402  
"synchronized"
1403  
" "
1404  
"void"
1405  
" "
1406  
"DiskSnippetCache_put"
1407  
""
1408  
"("
1409  
""
1410  
"long"
1411  
" "
1412  
"snippetID"
1413  
""
1414  
","
1415  
" "
1416  
"String"
1417  
" "
1418  
"snippet"
1419  
""
1420  
")"
1421  
" "
1422  
"throws"
1423  
" "
1424  
"IOException"
1425  
" "
1426  
"{"
1427  
"\n    "
1428  
"saveTextFile"
1429  
""
1430  
"("
1431  
""
1432  
"DiskSnippetCache_getFile"
1433  
""
1434  
"("
1435  
""
1436  
"snippetID"
1437  
""
1438  
")"
1439  
""
1440  
"."
1441  
""
1442  
"getPath"
1443  
""
1444  
"("
1445  
""
1446  
")"
1447  
""
1448  
","
1449  
" "
1450  
"snippet"
1451  
""
1452  
")"
1453  
""
1454  
";"
1455  
"\n  "
1456  
"}"
1457  
"\n\n  "
1458  
"public"
1459  
" "
1460  
"static"
1461  
" "
1462  
"File"
1463  
" "
1464  
"DiskSnippetCache_getDir"
1465  
""
1466  
"("
1467  
""
1468  
")"
1469  
" "
1470  
"{"
1471  
"\n    "
1472  
"return"
1473  
" "
1474  
"DiskSnippetCache_dir"
1475  
""
1476  
";"
1477  
"\n  "
1478  
"}"
1479  
"\n\n  "
1480  
"public"
1481  
" "
1482  
"static"
1483  
" "
1484  
"void"
1485  
" "
1486  
"initSnippetCache"
1487  
""
1488  
"("
1489  
""
1490  
")"
1491  
" "
1492  
"{"
1493  
"\n    "
1494  
"if"
1495  
" "
1496  
"("
1497  
""
1498  
"DiskSnippetCache_dir"
1499  
" "
1500  
"="
1501  
""
1502  
"="
1503  
" "
1504  
"null"
1505  
""
1506  
")"
1507  
"\n      "
1508  
"initDiskSnippetCache"
1509  
""
1510  
"("
1511  
""
1512  
"new"
1513  
" "
1514  
"File"
1515  
""
1516  
"("
1517  
""
1518  
"System"
1519  
""
1520  
"."
1521  
""
1522  
"getProperty"
1523  
""
1524  
"("
1525  
""
1526  
"\"user.home\""
1527  
""
1528  
")"
1529  
""
1530  
","
1531  
" "
1532  
"\".tinybrain/snippet-cache\""
1533  
""
1534  
")"
1535  
""
1536  
")"
1537  
""
1538  
";"
1539  
"\n  "
1540  
"}"
1541  
"\n  \n\n  /** writes safely (to temp file, then rename) */\n  "
1542  
"public"
1543  
" "
1544  
"static"
1545  
" "
1546  
"void"
1547  
" "
1548  
"saveTextFile"
1549  
""
1550  
"("
1551  
""
1552  
"String"
1553  
" "
1554  
"fileName"
1555  
""
1556  
","
1557  
" "
1558  
"String"
1559  
" "
1560  
"contents"
1561  
""
1562  
")"
1563  
" "
1564  
"throws"
1565  
" "
1566  
"IOException"
1567  
" "
1568  
"{"
1569  
"\n    "
1570  
"File"
1571  
" "
1572  
"file"
1573  
" "
1574  
"="
1575  
" "
1576  
"new"
1577  
" "
1578  
"File"
1579  
""
1580  
"("
1581  
""
1582  
"fileName"
1583  
""
1584  
")"
1585  
""
1586  
";"
1587  
"\n    "
1588  
"File"
1589  
" "
1590  
"parentFile"
1591  
" "
1592  
"="
1593  
" "
1594  
"file"
1595  
""
1596  
"."
1597  
""
1598  
"getParentFile"
1599  
""
1600  
"("
1601  
""
1602  
")"
1603  
""
1604  
";"
1605  
"\n    "
1606  
"if"
1607  
" "
1608  
"("
1609  
""
1610  
"parentFile"
1611  
" "
1612  
"!"
1613  
""
1614  
"="
1615  
" "
1616  
"null"
1617  
""
1618  
")"
1619  
"\n      "
1620  
"parentFile"
1621  
""
1622  
"."
1623  
""
1624  
"mkdirs"
1625  
""
1626  
"("
1627  
""
1628  
")"
1629  
""
1630  
";"
1631  
"\n    "
1632  
"String"
1633  
" "
1634  
"tempFileName"
1635  
" "
1636  
"="
1637  
" "
1638  
"fileName"
1639  
" "
1640  
"+"
1641  
" "
1642  
"\"_temp\""
1643  
""
1644  
";"
1645  
"\n    "
1646  
"FileOutputStream"
1647  
" "
1648  
"fileOutputStream"
1649  
" "
1650  
"="
1651  
" "
1652  
"new"
1653  
" "
1654  
"FileOutputStream"
1655  
""
1656  
"("
1657  
""
1658  
"tempFileName"
1659  
""
1660  
")"
1661  
""
1662  
";"
1663  
"\n    "
1664  
"OutputStreamWriter"
1665  
" "
1666  
"outputStreamWriter"
1667  
" "
1668  
"="
1669  
" "
1670  
"new"
1671  
" "
1672  
"OutputStreamWriter"
1673  
""
1674  
"("
1675  
""
1676  
"fileOutputStream"
1677  
""
1678  
","
1679  
" "
1680  
"\"UTF-8\""
1681  
""
1682  
")"
1683  
""
1684  
";"
1685  
"\n    "
1686  
"PrintWriter"
1687  
" "
1688  
"printWriter"
1689  
" "
1690  
"="
1691  
" "
1692  
"new"
1693  
" "
1694  
"PrintWriter"
1695  
""
1696  
"("
1697  
""
1698  
"outputStreamWriter"
1699  
""
1700  
")"
1701  
""
1702  
";"
1703  
"\n    "
1704  
"printWriter"
1705  
""
1706  
"."
1707  
""
1708  
"print"
1709  
""
1710  
"("
1711  
""
1712  
"contents"
1713  
""
1714  
")"
1715  
""
1716  
";"
1717  
"\n    "
1718  
"printWriter"
1719  
""
1720  
"."
1721  
""
1722  
"close"
1723  
""
1724  
"("
1725  
""
1726  
")"
1727  
""
1728  
";"
1729  
"\n    "
1730  
"if"
1731  
" "
1732  
"("
1733  
""
1734  
"file"
1735  
""
1736  
"."
1737  
""
1738  
"exists"
1739  
""
1740  
"("
1741  
""
1742  
")"
1743  
" "
1744  
"&"
1745  
""
1746  
"&"
1747  
" "
1748  
"!"
1749  
""
1750  
"file"
1751  
""
1752  
"."
1753  
""
1754  
"delete"
1755  
""
1756  
"("
1757  
""
1758  
")"
1759  
""
1760  
")"
1761  
"\n      "
1762  
"throw"
1763  
" "
1764  
"new"
1765  
" "
1766  
"IOException"
1767  
""
1768  
"("
1769  
""
1770  
"\"Can't delete \""
1771  
" "
1772  
"+"
1773  
" "
1774  
"fileName"
1775  
""
1776  
")"
1777  
""
1778  
";"
1779  
"\n\n    "
1780  
"if"
1781  
" "
1782  
"("
1783  
""
1784  
"!"
1785  
""
1786  
"new"
1787  
" "
1788  
"File"
1789  
""
1790  
"("
1791  
""
1792  
"tempFileName"
1793  
""
1794  
")"
1795  
""
1796  
"."
1797  
""
1798  
"renameTo"
1799  
""
1800  
"("
1801  
""
1802  
"file"
1803  
""
1804  
")"
1805  
""
1806  
")"
1807  
"\n      "
1808  
"throw"
1809  
" "
1810  
"new"
1811  
" "
1812  
"IOException"
1813  
""
1814  
"("
1815  
""
1816  
"\"Can't rename \""
1817  
" "
1818  
"+"
1819  
" "
1820  
"tempFileName"
1821  
" "
1822  
"+"
1823  
" "
1824  
"\" to \""
1825  
" "
1826  
"+"
1827  
" "
1828  
"fileName"
1829  
""
1830  
")"
1831  
""
1832  
";"
1833  
"\n  "
1834  
"}"
1835  
"\n\n  "
1836  
"public"
1837  
" "
1838  
"static"
1839  
" "
1840  
"String"
1841  
" "
1842  
"loadTextFile"
1843  
""
1844  
"("
1845  
""
1846  
"String"
1847  
" "
1848  
"fileName"
1849  
""
1850  
","
1851  
" "
1852  
"String"
1853  
" "
1854  
"defaultContents"
1855  
""
1856  
")"
1857  
" "
1858  
"throws"
1859  
" "
1860  
"IOException"
1861  
" "
1862  
"{"
1863  
"\n    "
1864  
"if"
1865  
" "
1866  
"("
1867  
""
1868  
"!"
1869  
""
1870  
"new"
1871  
" "
1872  
"File"
1873  
""
1874  
"("
1875  
""
1876  
"fileName"
1877  
""
1878  
")"
1879  
""
1880  
"."
1881  
""
1882  
"exists"
1883  
""
1884  
"("
1885  
""
1886  
")"
1887  
""
1888  
")"
1889  
"\n      "
1890  
"return"
1891  
" "
1892  
"defaultContents"
1893  
""
1894  
";"
1895  
"\n\n    "
1896  
"FileInputStream"
1897  
" "
1898  
"fileInputStream"
1899  
" "
1900  
"="
1901  
" "
1902  
"new"
1903  
" "
1904  
"FileInputStream"
1905  
""
1906  
"("
1907  
""
1908  
"fileName"
1909  
""
1910  
")"
1911  
""
1912  
";"
1913  
"\n    "
1914  
"InputStreamReader"
1915  
" "
1916  
"inputStreamReader"
1917  
" "
1918  
"="
1919  
" "
1920  
"new"
1921  
" "
1922  
"InputStreamReader"
1923  
""
1924  
"("
1925  
""
1926  
"fileInputStream"
1927  
""
1928  
","
1929  
" "
1930  
"\"UTF-8\""
1931  
""
1932  
")"
1933  
""
1934  
";"
1935  
"\n    "
1936  
"return"
1937  
" "
1938  
"loadTextFile"
1939  
""
1940  
"("
1941  
""
1942  
"inputStreamReader"
1943  
""
1944  
")"
1945  
""
1946  
";"
1947  
"\n  "
1948  
"}"
1949  
"\n\n  "
1950  
"public"
1951  
" "
1952  
"static"
1953  
" "
1954  
"String"
1955  
" "
1956  
"loadTextFile"
1957  
""
1958  
"("
1959  
""
1960  
"Reader"
1961  
" "
1962  
"reader"
1963  
""
1964  
")"
1965  
" "
1966  
"throws"
1967  
" "
1968  
"IOException"
1969  
" "
1970  
"{"
1971  
"\n    "
1972  
"StringBuilder"
1973  
" "
1974  
"builder"
1975  
" "
1976  
"="
1977  
" "
1978  
"new"
1979  
" "
1980  
"StringBuilder"
1981  
""
1982  
"("
1983  
""
1984  
")"
1985  
""
1986  
";"
1987  
"\n    "
1988  
"try"
1989  
" "
1990  
"{"
1991  
"\n      "
1992  
"BufferedReader"
1993  
" "
1994  
"bufferedReader"
1995  
" "
1996  
"="
1997  
" "
1998  
"new"
1999  
" "
2000  
"BufferedReader"
2001  
""
2002  
"("
2003  
""
2004  
"reader"
2005  
""
2006  
")"
2007  
""
2008  
";"
2009  
"\n      "
2010  
"String"
2011  
" "
2012  
"line"
2013  
""
2014  
";"
2015  
"\n      "
2016  
"while"
2017  
" "
2018  
"("
2019  
""
2020  
"("
2021  
""
2022  
"line"
2023  
" "
2024  
"="
2025  
" "
2026  
"bufferedReader"
2027  
""
2028  
"."
2029  
""
2030  
"readLine"
2031  
""
2032  
"("
2033  
""
2034  
")"
2035  
""
2036  
")"
2037  
" "
2038  
"!"
2039  
""
2040  
"="
2041  
" "
2042  
"null"
2043  
""
2044  
")"
2045  
"\n        "
2046  
"builder"
2047  
""
2048  
"."
2049  
""
2050  
"append"
2051  
""
2052  
"("
2053  
""
2054  
"line"
2055  
""
2056  
")"
2057  
""
2058  
"."
2059  
""
2060  
"append"
2061  
""
2062  
"("
2063  
""
2064  
"'\\n'"
2065  
""
2066  
")"
2067  
""
2068  
";"
2069  
"\n    "
2070  
"}"
2071  
" "
2072  
"finally"
2073  
" "
2074  
"{"
2075  
"\n      "
2076  
"reader"
2077  
""
2078  
"."
2079  
""
2080  
"close"
2081  
""
2082  
"("
2083  
""
2084  
")"
2085  
""
2086  
";"
2087  
"\n    "
2088  
"}"
2089  
"\n    "
2090  
"return"
2091  
" "
2092  
"builder"
2093  
""
2094  
"."
2095  
""
2096  
"length"
2097  
""
2098  
"("
2099  
""
2100  
")"
2101  
" "
2102  
"="
2103  
""
2104  
"="
2105  
" "
2106  
"0"
2107  
" "
2108  
"?"
2109  
" "
2110  
"\"\""
2111  
" "
2112  
":"
2113  
" "
2114  
"builder"
2115  
""
2116  
"."
2117  
""
2118  
"substring"
2119  
""
2120  
"("
2121  
""
2122  
"0"
2123  
""
2124  
","
2125  
" "
2126  
"builder"
2127  
""
2128  
"."
2129  
""
2130  
"length"
2131  
""
2132  
"("
2133  
""
2134  
")"
2135  
""
2136  
"-"
2137  
""
2138  
"1"
2139  
""
2140  
")"
2141  
""
2142  
";"
2143  
"\n  "
2144  
"}"
2145  
"\n"
2146  
"}"
2147  
""

download  show line numbers   

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: 486 / 340
Referenced in: [show references]