From 58eac3464db786795a1328daa58f56dcef94c696 Mon Sep 17 00:00:00 2001 From: Alexander Puck Neuwirth Date: Sat, 30 Jul 2022 12:41:00 +0200 Subject: [PATCH] Fix tuo path to sys install default --- LICENSE.md | 22 + data/cards_section_1.xml | 3294 +++++++++++++++++ .../Alexander/TU/TUO/TUO.java | 2 +- .../Alexander/TU/util/FileIO.java | 83 +- .../Alexander/TU/util/Log.java | 113 +- .../Alexander/TU/util/StreamUtil.java | 13 + .../Alexander/TU/util/Wget.java | 3 + 7 files changed, 3462 insertions(+), 68 deletions(-) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..91f233a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2018 Silverglint - Creative Software + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/data/cards_section_1.xml b/data/cards_section_1.xml index 72737cc..8ff59d1 100644 --- a/data/cards_section_1.xml +++ b/data/cards_section_1.xml @@ -23275,4 +23275,3298 @@ + + + 2000150 + + 0 + 0 + simgentest + 2 + 5 + 7 + 21 + 2 + + + + + + 2000151 + 2 + + + + + + + 2000152 + 3 + + + + + + + 2000153 + 4 + + + + + + + 2000154 + 5 + + + + + + + 2000155 + 6 + + + + + + + + + 2000157 + + 0 + 0 + simgentest_ASS + 3 + 5 + 6 + 23 + 2 + + + + + + 2000158 + 2 + + + + + + + 2000159 + 3 + + + + + + + 2000160 + 4 + + + + + + + 2000161 + 5 + + + + + + + 2000162 + 6 + + + + + + + + + 26742 + + 0 + 0 + simgentest_COM + 1 + 2 + 2 + 0 + 52 + + + + + + 26743 + 2 + + + + + + + 26744 + 3 + + + + + + + 26745 + 4 + + + + + + + 26746 + 5 + + + + + + + 26747 + 6 + + + + + + + + + 50512 + + 0 + 0 + simgentest_DOM + 3 + 4 + 12 + 4 + + + + + + 50513 + 2 + + + + + + + 50514 + 3 + + + + + + + 50515 + 4 + + + + + + + 50516 + 5 + + + + + + + 50517 + 6 + + + + + + + + + 2000164 + + 0 + 0 + simgentest2_ASS + 3 + 4 + 8 + 22 + 2 + + + + + + 2000165 + 2 + + + + + + + 2000166 + 3 + + + + + + + 2000167 + 4 + + + + + + + 2000168 + 5 + + + + + + + 2000169 + 6 + + + + + + + + + 26749 + + 0 + 0 + simgentest2_COM + 1 + 2 + 1 + 0 + 48 + + + + + + 26750 + 2 + + + + + + + 26751 + 3 + + + + + + + 26752 + 4 + + + + + + + 26753 + 5 + + + + + + + 26754 + 6 + + + + + + + + + 50519 + + 0 + 0 + simgentest2_DOM + 2 + 6 + 11 + 4 + + + + + + 50520 + 2 + + + + + + + 50521 + 3 + + + + + + + 50522 + 4 + + + + + + + 50523 + 5 + + + + + + + 50524 + 6 + + + + + + + + + 2000170 + + 0 + 0 + simgentest + 2 + 2 + 7 + 23 + 2 + + + + + + 2000171 + 2 + + + + + + + 2000172 + 3 + + + + + + + 2000173 + 4 + + + + + + + 2000174 + 5 + + + + + + + 2000175 + 6 + + + + + + + + + 2000177 + + 0 + 0 + simgentest_ASS + 5 + 2 + 7 + 25 + 3 + + + + + + 2000178 + 2 + + + + + + + 2000179 + 3 + + + + + + + 2000180 + 4 + + + + + + + 2000181 + 5 + + + + + + + 2000182 + 6 + + + + + + + + + 26756 + + 0 + 0 + simgentest_COM + 3 + 1 + 0 + 50 + + + + + + 26757 + 2 + + + + + + + 26758 + 3 + + + + + + + 26759 + 4 + + + + + + + 26760 + 5 + + + + + + + 26761 + 6 + + + + + + + + + 50525 + + 0 + 0 + simgentest_DOM + 3 + 2 + 7 + 4 + + + + + + 50526 + 2 + + + + + + + 50527 + 3 + + + + + + + 50528 + 4 + + + + + + + 50529 + 5 + + + + + + + 50530 + 6 + + + + + + + + + 2000184 + + 0 + 0 + simgentest2_ASS + 2 + 2 + 2 + 9 + 26 + 1 + + + + + + 2000185 + 2 + + + + + + + 2000186 + 3 + + + + + + + 2000187 + 4 + + + + + + + 2000188 + 5 + + + + + + + 2000189 + 6 + + + + + + + + + 26763 + + 0 + 0 + simgentest2_COM + 1 + 5 + 0 + 48 + + + + + + 26764 + 2 + + + + + + + 26765 + 3 + + + + + + + 26766 + 4 + + + + + + + 26767 + 5 + + + + + + + 26768 + 6 + + + + + + + + + 50532 + + 0 + 0 + simgentest2_DOM + 2 + 3 + 6 + 10 + 3 + + + + + + 50533 + 2 + + + + + + + 50534 + 3 + + + + + + + 50535 + 4 + + + + + + + 50536 + 5 + + + + + + + 50537 + 6 + + + + + + + + + 2000190 + + 0 + 0 + simgentest + 2 + 2 + 5 + 9 + 23 + 2 + + + + + + 2000191 + 2 + + + + + + + 2000192 + 3 + + + + + + + 2000193 + 4 + + + + + + + 2000194 + 5 + + + + + + + 2000195 + 6 + + + + + + + + + 2000197 + + 0 + 0 + simgentest_ASS + 2 + 1 + 6 + 12 + 21 + 3 + + + + + + 2000198 + 2 + + + + + + + 2000199 + 3 + + + + + + + 2000200 + 4 + + + + + + + 2000201 + 5 + + + + + + + 2000202 + 6 + + + + + + + + + 26769 + + 0 + 0 + simgentest_COM + 1 + 1 + 6 + 1 + 48 + + + + + + 26770 + 2 + + + + + + + 26771 + 3 + + + + + + + 26772 + 4 + + + + + + + 26773 + 5 + + + + + + + 26774 + 6 + + + + + + + + + 50538 + + 0 + 0 + simgentest_DOM + 1 + 4 + 9 + 4 + + + + + + 50539 + 2 + + + + + + + 50540 + 3 + + + + + + + 50541 + 4 + + + + + + + 50542 + 5 + + + + + + + 50543 + 6 + + + + + + + + + 2000204 + + 0 + 0 + simgentest2_ASS + 2 + 3 + 2 + 7 + 21 + 2 + + + + + + 2000205 + 2 + + + + + + + 2000206 + 3 + + + + + + + 2000207 + 4 + + + + + + + 2000208 + 5 + + + + + + + 2000209 + 6 + + + + + + + + + 26776 + + 0 + 0 + simgentest2_COM + 3 + 1 + 0 + 54 + + + + + + 26777 + 2 + + + + + + + 26778 + 3 + + + + + + + 26779 + 4 + + + + + + + 26780 + 5 + + + + + + + 26781 + 6 + + + + + + + + + 50545 + + 0 + 0 + simgentest2_DOM + 2 + 2 + 3 + 11 + 4 + + + + + + 50546 + 2 + + + + + + + 50547 + 3 + + + + + + + 50548 + 4 + + + + + + + 50549 + 5 + + + + + + + 50550 + 6 + + + + + + + + + 2000210 + + 0 + 0 + simgentest + 1 + 4 + 5 + 4 + 20 + 2 + + + + + + 2000211 + 2 + + + + + + + 2000212 + 3 + + + + + + + 2000213 + 4 + + + + + + + 2000214 + 5 + + + + + + + 2000215 + 6 + + + + + + + + + 2000217 + + 0 + 0 + simgentest_ASS + 3 + 6 + 7 + 25 + 3 + + + + + + 2000218 + 2 + + + + + + + 2000219 + 3 + + + + + + + 2000220 + 4 + + + + + + + 2000221 + 5 + + + + + + + 2000222 + 6 + + + + + + + + + 26782 + + 0 + 0 + simgentest_COM + 3 + 3 + 1 + 51 + + + + + + 26783 + 2 + + + + + + + 26784 + 3 + + + + + + + 26785 + 4 + + + + + + + 26786 + 5 + + + + + + + 26787 + 6 + + + + + + + + + 50551 + + 0 + 0 + simgentest_DOM + 2 + 3 + 3 + 9 + 3 + + + + + + 50552 + 2 + + + + + + + 50553 + 3 + + + + + + + 50554 + 4 + + + + + + + 50555 + 5 + + + + + + + 50556 + 6 + + + + + + + + + 2000224 + + 0 + 0 + simgentest2_ASS + 1 + 3 + 10 + 27 + 1 + + + + + + 2000225 + 2 + + + + + + + 2000226 + 3 + + + + + + + 2000227 + 4 + + + + + + + 2000228 + 5 + + + + + + + 2000229 + 6 + + + + + + + + + 26789 + + 0 + 0 + simgentest2_COM + 1 + 1 + 1 + 0 + 51 + + + + + + 26790 + 2 + + + + + + + 26791 + 3 + + + + + + + 26792 + 4 + + + + + + + 26793 + 5 + + + + + + + 26794 + 6 + + + + + + + + + 50558 + + 0 + 0 + simgentest2_DOM + 2 + 2 + 3 + 11 + 3 + + + + + + 50559 + 2 + + + + + + + 50560 + 3 + + + + + + + 50561 + 4 + + + + + + + 50562 + 5 + + + + + + + 50563 + 6 + + + + + + + + + 2000230 + + 0 + 0 + simgentest + 1 + 2 + 11 + 26 + 2 + + + + + + 2000231 + 2 + + + + + + + 2000232 + 3 + + + + + + + 2000233 + 4 + + + + + + + 2000234 + 5 + + + + + + + 2000235 + 6 + + + + + + + + + 2000237 + + 0 + 0 + simgentest_ASS + 2 + 2 + 2 + 9 + 23 + 2 + + + + + + 2000238 + 2 + + + + + + + 2000239 + 3 + + + + + + + 2000240 + 4 + + + + + + + 2000241 + 5 + + + + + + + 2000242 + 6 + + + + + + + + + 26795 + + 0 + 0 + simgentest_COM + 2 + 2 + 0 + 47 + + + + + + 26796 + 2 + + + + + + + 26797 + 3 + + + + + + + 26798 + 4 + + + + + + + 26799 + 5 + + + + + + + 26800 + 6 + + + + + + + + + 50564 + + 0 + 0 + simgentest_DOM + 1 + 4 + 6 + 4 + + + + + + 50565 + 2 + + + + + + + 50566 + 3 + + + + + + + 50567 + 4 + + + + + + + 50568 + 5 + + + + + + + 50569 + 6 + + + + + + + + + 2000244 + + 0 + 0 + simgentest2_ASS + 3 + 6 + 9 + 24 + 3 + + + + + + 2000245 + 2 + + + + + + + 2000246 + 3 + + + + + + + 2000247 + 4 + + + + + + + 2000248 + 5 + + + + + + + 2000249 + 6 + + + + + + + + + 26804 + + 0 + 0 + simgentest2_COM + 2 + 1 + 0 + 46 + + + + + + 26805 + 2 + + + + + + + 26806 + 3 + + + + + + + 26807 + 4 + + + + + + + 26808 + 5 + + + + + + + 26809 + 6 + + + + + + + + + 50571 + + 0 + 0 + simgentest2_DOM + 1 + 3 + 16 + 4 + + + + + + 50572 + 2 + + + + + + + 50573 + 3 + + + + + + + 50574 + 4 + + + + + + + 50575 + 5 + + + + + + + 50576 + 6 + + + + + + + + + 2000250 + + 0 + 0 + simgentest + 2 + 2 + 8 + 21 + 3 + + + + + + 2000251 + 2 + + + + + + + 2000252 + 3 + + + + + + + 2000253 + 4 + + + + + + + 2000254 + 5 + + + + + + + 2000255 + 6 + + + + + + + + + 2000257 + + 0 + 0 + simgentest2 + 1 + 1 + 2 + 7 + 22 + 2 + + + + + + 2000258 + 2 + + + + + + + 2000259 + 3 + + + + + + + 2000260 + 4 + + + + + + + 2000261 + 5 + + + + + + + 2000262 + 6 + + + + + + + + + 2000264 + + 0 + 0 + simgentest_ASS + 1 + 1 + 9 + 22 + 2 + + + + + + 2000265 + 2 + + + + + + + 2000266 + 3 + + + + + + + 2000267 + 4 + + + + + + + 2000268 + 5 + + + + + + + 2000269 + 6 + + + + + + + + + 26811 + + 0 + 0 + simgentest_COM + 3 + 2 + 0 + 44 + + + + + + 26812 + 2 + + + + + + + 26813 + 3 + + + + + + + 26814 + 4 + + + + + + + 26815 + 5 + + + + + + + 26816 + 6 + + + + + + + + + 50577 + + 0 + 0 + simgentest_DOM + 4 + 2 + 8 + 4 + + + + + + 50578 + 2 + + + + + + + 50579 + 3 + + + + + + + 50580 + 4 + + + + + + + 50581 + 5 + + + + + + + 50582 + 6 + + + + + + + + + 2000271 + + 0 + 0 + simgentest2_ASS + 1 + 2 + 5 + 9 + 24 + 1 + + + + + + 2000272 + 2 + + + + + + + 2000273 + 3 + + + + + + + 2000274 + 4 + + + + + + + 2000275 + 5 + + + + + + + 2000276 + 6 + + + + + + + + + 26818 + + 0 + 0 + simgentest2_COM + 3 + 5 + 0 + 46 + + + + + + 26819 + 2 + + + + + + + 26820 + 3 + + + + + + + 26821 + 4 + + + + + + + 26822 + 5 + + + + + + + 26823 + 6 + + + + + + + + + 50584 + + 0 + 0 + simgentest2_DOM + 4 + 1 + 10 + 4 + + + + + + 50585 + 2 + + + + + + + 50586 + 3 + + + + + + + 50587 + 4 + + + + + + + 50588 + 5 + + + + + + + 50589 + 6 + + + + + + + + + 2000277 + + 0 + 0 + simgentest + 2 + 4 + 8 + 23 + 2 + + + + + + 2000278 + 2 + + + + + + + 2000279 + 3 + + + + + + + 2000280 + 4 + + + + + + + 2000281 + 5 + + + + + + + 2000282 + 6 + + + + + + + + + 2000284 + + 0 + 0 + simgentest_ASS + 2 + 2 + 8 + 23 + 1 + + + + + + 2000285 + 2 + + + + + + + 2000286 + 3 + + + + + + + 2000287 + 4 + + + + + + + 2000288 + 5 + + + + + + + 2000289 + 6 + + + + + + + + + 26824 + + 0 + 0 + simgentest_COM + 4 + 5 + 0 + 43 + + + + + + 26825 + 2 + + + + + + + 26826 + 3 + + + + + + + 26827 + 4 + + + + + + + 26828 + 5 + + + + + + + 26829 + 6 + + + + + + + + + 50590 + + 0 + 0 + simgentest_DOM + 1 + 3 + 5 + 9 + 4 + + + + + + 50591 + 2 + + + + + + + 50592 + 3 + + + + + + + 50593 + 4 + + + + + + + 50594 + 5 + + + + + + + 50595 + 6 + + + + + + + + + 2000291 + + 0 + 0 + simgentest2_ASS + 2 + 3 + 5 + 22 + 2 + + + + + + 2000292 + 2 + + + + + + + 2000293 + 3 + + + + + + + 2000294 + 4 + + + + + + + 2000295 + 5 + + + + + + + 2000296 + 6 + + + + + + + + + 26831 + + 0 + 0 + simgentest2_COM + 1 + 4 + 5 + 1 + 43 + + + + + + 26832 + 2 + + + + + + + 26833 + 3 + + + + + + + 26834 + 4 + + + + + + + 26835 + 5 + + + + + + + 26836 + 6 + + + + + + + + + 50597 + + 0 + 0 + simgentest2_DOM + 3 + 3 + 7 + 3 + + + + + + 50598 + 2 + + + + + + + 50599 + 3 + + + + + + + 50600 + 4 + + + + + + + 50601 + 5 + + + + + + + 50602 + 6 + + + + + + + + + 2000297 + + 0 + 0 + simgentest + 1 + 2 + 1 + 6 + 21 + 1 + + + + + + 2000298 + 2 + + + + + + + 2000299 + 3 + + + + + + + 2000300 + 4 + + + + + + + 2000301 + 5 + + + + + + + 2000302 + 6 + + + + + + + + + 2000304 + + 0 + 0 + simgentest2 + 2 + 5 + 7 + 24 + 2 + + + + + + 2000305 + 2 + + + + + + + 2000306 + 3 + + + + + + + 2000307 + 4 + + + + + + + 2000308 + 5 + + + + + + + 2000309 + 6 + + + + + + + + + 2000311 + + 0 + 0 + simgentest_ASS + 3 + 2 + 9 + 22 + 2 + + + + + + 2000312 + 2 + + + + + + + 2000313 + 3 + + + + + + + 2000314 + 4 + + + + + + + 2000315 + 5 + + + + + + + 2000316 + 6 + + + + + + + + + 26837 + + 0 + 0 + simgentest_COM + 3 + 4 + 1 + 49 + + + + + + 26838 + 2 + + + + + + + 26839 + 3 + + + + + + + 26840 + 4 + + + + + + + 26841 + 5 + + + + + + + 26842 + 6 + + + + + + + + + 50605 + + 0 + 0 + simgentest_DOM + 3 + 5 + 10 + 4 + + + + + + 50606 + 2 + + + + + + + 50607 + 3 + + + + + + + 50608 + 4 + + + + + + + 50609 + 5 + + + + + + + 50610 + 6 + + + + + + + + + 2000318 + + 0 + 0 + simgentest2_ASS + 3 + 4 + 8 + 25 + 1 + + + + + + 2000319 + 2 + + + + + + + 2000320 + 3 + + + + + + + 2000321 + 4 + + + + + + + 2000322 + 5 + + + + + + + 2000323 + 6 + + + + + + + + + 26844 + + 0 + 0 + simgentest2_COM + 1 + 1 + 1 + 0 + 54 + + + + + + 26845 + 2 + + + + + + + 26846 + 3 + + + + + + + 26847 + 4 + + + + + + + 26848 + 5 + + + + + + + 26849 + 6 + + + + + + + + + 50612 + + 0 + 0 + simgentest2_DOM + 2 + 6 + 13 + 3 + + + + + + 50613 + 2 + + + + + + + 50614 + 3 + + + + + + + 50615 + 4 + + + + + + + 50616 + 5 + + + + + + + 50617 + 6 + + + + + + \ No newline at end of file diff --git a/src/main/java/de/neuwirthinformatik/Alexander/TU/TUO/TUO.java b/src/main/java/de/neuwirthinformatik/Alexander/TU/TUO/TUO.java index 5b5d5dc..e247f89 100755 --- a/src/main/java/de/neuwirthinformatik/Alexander/TU/TUO/TUO.java +++ b/src/main/java/de/neuwirthinformatik/Alexander/TU/TUO/TUO.java @@ -17,7 +17,7 @@ public class TUO { public static int threads = 1; - public static String tuo = "./tuo"; + public static String tuo = "tuo"; public static boolean force_full_deck = false; public static boolean tuo_out = true; public static final String wd = ""; diff --git a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/FileIO.java b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/FileIO.java index 7f330f3..ae642aa 100644 --- a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/FileIO.java +++ b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/FileIO.java @@ -1,9 +1,13 @@ package de.neuwirthinformatik.Alexander.TU.util; +import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStreamReader; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; @@ -15,6 +19,7 @@ public static void deleteFile(String file) { if (f.exists()) f.delete(); } + public static void createFile(String file) { File f = new File(file); if (!f.exists()) @@ -24,7 +29,12 @@ public static void createFile(String file) { e.printStackTrace(); } } + public static String readFile(String path) { + return readFileUsingFiles(path); + } + + public static String readFileUsingFiles(String path) { byte[] encoded; try { encoded = Files.readAllBytes(Paths.get(path)); @@ -34,6 +44,29 @@ public static String readFile(String path) { } return ""; } + + public static String readFileUsingFileInputStream(String file) { + FileInputStream fin = null; + String ret = ""; + try { + fin = new FileInputStream(file); + ret = StreamUtil.convertStreamToString(fin); + } catch (Exception e) { + e.printStackTrace(); + + // Log.e("Exception", "File read failed: " + e.toString()); + } finally { + try { + if (fin != null) + fin.close(); + } catch (IOException e) { + e.printStackTrace(); + // Log.e("Exception", "File close failed: " + e.toString()); + } + } + return ret; + } + public static void copyFile(String src, String dst) { try { Files.copy(new File(src).toPath(), new File(dst).toPath(), StandardCopyOption.REPLACE_EXISTING); @@ -41,9 +74,11 @@ public static void copyFile(String src, String dst) { e.printStackTrace(); } } + public static void appendLine(String file, String... lines) { - appendLines(file,lines); + appendLines(file, lines); } + public static void appendLine(String file, String line) { File f = new File(file); if (!f.exists()) { @@ -65,6 +100,7 @@ public static void appendLine(String file, String line) { e.printStackTrace(); } } + public static void appendLines(String file, String[] lines) { File f = new File(file); if (!f.exists()) { @@ -87,4 +123,49 @@ public static void appendLines(String file, String[] lines) { e.printStackTrace(); } } + + public static String readFirstLine(String file) { + FileInputStream fin = null; + BufferedReader reader = null; + String ret = ""; + try { + fin = new FileInputStream(file); + reader = new BufferedReader(new InputStreamReader(fin)); + ret = reader.readLine(); + } catch (Exception e) { + e.printStackTrace(); + + // Log.e("Exception", "File read failed: " + e.toString()); + } finally { + try { + if (reader != null) + reader.close(); + if (fin != null) + fin.close(); + } catch (IOException e) { + e.printStackTrace(); + // Log.e("Exception", "File close failed: " + e.toString()); + } + } + return ret; + } + + public static void writeToFile(String file, String data) { + FileOutputStream stream = null; + try { + stream = new FileOutputStream(file); + stream.write(data.getBytes()); + } catch (IOException e) { + e.printStackTrace(); + // Log.e("Exception", "File write failed: " + e.toString()); + } finally { + try { + if (stream != null) + stream.close(); + } catch (IOException e) { + e.printStackTrace(); + // Log.e("Exception", "File close failed: " + e.toString()); + } + } + } } diff --git a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Log.java b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Log.java index 34df714..b23a2ec 100755 --- a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Log.java +++ b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Log.java @@ -24,82 +24,63 @@ import de.neuwirthinformatik.Alexander.TU.TU; -public class Log -{ +public class Log { private static int MAX = 10; - public static class NoLog extends Log - { + + public static class NoLog extends Log { @Override - public void print(String msg, Level l,String[] src) {} + public void print(String msg, Level l, String[] src) { + } } - //private File f = new File("logs/" + new SimpleDateFormat("yyyyMMdd-HH-mm-ss").format(new Date()) + ".log"); - - //private BufferedWriter output; + // private File f = new File("logs/" + new + // SimpleDateFormat("yyyyMMdd-HH-mm-ss").format(new Date()) + ".log"); + + // private BufferedWriter output; private JTabbedPane tabbedPane; - - - - public Log() - { - - - /*if(!f.exists()){ - if(f.getParentFile()!= null)f.getParentFile().mkdirs(); - try { - f.createNewFile(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - try { - output = new BufferedWriter(new FileWriter(f, true));; - } catch (IOException e) { - e.printStackTrace(); - }*/ - - - + + public Log() { + + /* + * if(!f.exists()){ if(f.getParentFile()!= null)f.getParentFile().mkdirs(); try + * { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch + * block e.printStackTrace(); } } + * + * try { output = new BufferedWriter(new FileWriter(f, true));; } catch + * (IOException e) { e.printStackTrace(); } + */ + } - - - - public void print(String msg, Level l,String[] src) - { - String date = "[" + new SimpleDateFormat("HH:mm:ss").format( new Date() ) + "]: "; - Style s = null;//hm_style.get(l); + + public void print(String msg, Level l, String[] src) { + String date = "[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "]: "; + Style s = null;// hm_style.get(l); String src_string = ""; - for(String st : src)src_string += st + ","; - - System.out.println(date + "{" +src_string+"}: "+ msg); - + for (String st : src) + src_string += st + ","; + + System.out.println(date + "{" + src_string + "}: " + msg); + } - - public void log(Level l, String msg,String... src) - { - print(msg,l,src); + + public void log(Level l, String msg, String... src) { + print(msg, l, src); } - - public void e(String msg,String... src) - { - log(Level.SEVERE,"(ERROR)"+msg, src); + + public void e(String msg, String... src) { + log(Level.SEVERE, "(ERROR)" + msg, src); } - - public void w(String msg,String... src) - { - log(Level.WARNING,"(WARNING)"+msg, src); + + public void w(String msg, String... src) { + log(Level.WARNING, "(WARNING)" + msg, src); } - - public void m(String msg,String... src) - { - log(Level.INFO,msg, src); + + public void m(String msg, String... src) { + log(Level.INFO, msg, src); } - - public void d(String msg,String... src) - { - if(TU.settings.DEBUG_LOGGING)log(Level.CONFIG,"(DEBUG)"+msg, src); + + public void d(String msg, String... src) { + if (TU.settings.DEBUG_LOGGING) + log(Level.CONFIG, "(DEBUG)" + msg, src); } - - + } diff --git a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/StreamUtil.java b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/StreamUtil.java index 4bb330c..1e9ac2b 100755 --- a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/StreamUtil.java +++ b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/StreamUtil.java @@ -1,8 +1,10 @@ package de.neuwirthinformatik.Alexander.TU.util; +import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; public class StreamUtil { @@ -20,4 +22,15 @@ private static ByteArrayOutputStream readFully(InputStream inputStream) throws I } return baos; } + + public static String convertStreamToString(InputStream is) throws Exception { + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder sb = new StringBuilder(); + String line = null; + while ((line = reader.readLine()) != null) { + sb.append(line).append("\n"); + } + reader.close(); + return sb.toString(); + } } diff --git a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Wget.java b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Wget.java index cf924c2..9d0eee1 100755 --- a/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Wget.java +++ b/src/main/java/de/neuwirthinformatik/Alexander/TU/util/Wget.java @@ -108,10 +108,13 @@ public static String wGet(String urlOfFile) { } public static Wget.Status wGet(String saveAsFile, String urlOfFile) { + File yourFile = new File(saveAsFile); InputStream httpIn = null; OutputStream fileOutput = null; OutputStream bufferedOut = null; try { + yourFile.getParentFile().mkdirs(); + yourFile.createNewFile(); // if file already exists will do nothing // check the http connection before we do anything to the fs httpIn = new BufferedInputStream(new URL(urlOfFile).openStream()); // prep saving the file