| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 return array.toString(); | 96 return array.toString(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 public static String readAssetAsString(Context context, String filename) throw
s IOException | 99 public static String readAssetAsString(Context context, String filename) throw
s IOException |
| 100 { | 100 { |
| 101 BufferedReader in = null; | 101 BufferedReader in = null; |
| 102 try { | 102 try |
| 103 { |
| 103 StringBuilder buf = new StringBuilder(); | 104 StringBuilder buf = new StringBuilder(); |
| 104 InputStream is = context.getAssets().open(filename); | 105 InputStream is = context.getAssets().open(filename); |
| 105 in = new BufferedReader(new InputStreamReader(is)); | 106 in = new BufferedReader(new InputStreamReader(is)); |
| 106 | 107 |
| 107 String str; | 108 String str; |
| 108 boolean isFirst = true; | 109 boolean isFirst = true; |
| 109 while ( (str = in.readLine()) != null ) { | 110 while ((str = in.readLine()) != null) |
| 111 { |
| 110 if (isFirst) | 112 if (isFirst) |
| 113 { |
| 111 isFirst = false; | 114 isFirst = false; |
| 115 } |
| 112 else | 116 else |
| 117 { |
| 113 buf.append('\n'); | 118 buf.append('\n'); |
| 119 } |
| 114 buf.append(str); | 120 buf.append(str); |
| 115 } | 121 } |
| 116 return buf.toString(); | 122 return buf.toString(); |
| 117 } finally { | 123 } |
| 118 if (in != null) { | 124 finally |
| 119 try { | 125 { |
| 126 if (in != null) |
| 127 { |
| 128 try |
| 129 { |
| 120 in.close(); | 130 in.close(); |
| 121 } catch (IOException e) { | 131 } |
| 132 catch (IOException e) |
| 133 { |
| 122 // ignored | 134 // ignored |
| 123 } | 135 } |
| 124 } | 136 } |
| 125 } | 137 } |
| 126 } | 138 } |
| 127 } | 139 } |
| OLD | NEW |