Changeset 7037 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-05-01T16:28:25+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
r7033 r7037 38 38 * audioFormat.getFrameSize() /* bytes per frame */; 39 39 double naturalLength = filesize / bytesPerSecond; 40 Utils.close(audioInputStream);41 40 double calibration = Main.pref.getDouble("audio.calibration", 1.0 /* default, ratio */); 42 41 return naturalLength / calibration; -
trunk/src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
r6925 r7037 211 211 */ 212 212 public static URL getBugReportUrl(String debugText) { 213 try {213 try ( 214 214 ByteArrayOutputStream out = new ByteArrayOutputStream(); 215 GZIPOutputStream gzip = new GZIPOutputStream(out); 215 GZIPOutputStream gzip = new GZIPOutputStream(out) 216 ) { 216 217 gzip.write(debugText.getBytes(Utils.UTF_8)); 217 Utils.close(gzip);218 218 219 219 return new URL(Main.getJOSMWebsite()+"/josmticket?" + -
trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java
r7033 r7037 200 200 // Try lsb_release (only available on LSB-compliant Linux systems, see https://www.linuxbase.org/lsb-cert/productdir.php?by_prod ) 201 201 Process p = Runtime.getRuntime().exec("lsb_release -ds"); 202 BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), Utils.UTF_8));203 String line = Utils.strip(input.readLine());204 Utils.close(input);205 if (line != null && !line.isEmpty()) {206 line = line.replaceAll("\"+","");207 line = line.replaceAll("NAME=",""); // strange code for some Gentoo's208 if(line.startsWith("Linux ")) // e.g. Linux Mint209 return line;210 else if(!line.isEmpty())211 return "Linux " + line;202 try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), Utils.UTF_8))) { 203 String line = Utils.strip(input.readLine()); 204 if (line != null && !line.isEmpty()) { 205 line = line.replaceAll("\"+",""); 206 line = line.replaceAll("NAME=",""); // strange code for some Gentoo's 207 if(line.startsWith("Linux ")) // e.g. Linux Mint 208 return line; 209 else if(!line.isEmpty()) 210 return "Linux " + line; 211 } 212 212 } 213 213 } catch (IOException e) { -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r7019 r7037 801 801 } 802 802 Process p = new ProcessBuilder(command).start(); 803 BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8));804 StringBuilder all = null;805 String line;806 while ((line = input.readLine()) != null) {807 if (all == null) {808 all = new StringBuilder(line);809 } else {810 all.append("\n");811 all.append(line);812 }813 }814 Utils.close(input);815 return all != null ? all.toString() : null;803 try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))) { 804 StringBuilder all = null; 805 String line; 806 while ((line = input.readLine()) != null) { 807 if (all == null) { 808 all = new StringBuilder(line); 809 } else { 810 all.append("\n"); 811 all.append(line); 812 } 813 } 814 return all != null ? all.toString() : null; 815 } 816 816 } 817 817
Note: See TracChangeset
for help on using the changeset viewer.