MyUtility.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package epson.server.utils;
  2. import android.content.Context;
  3. import com.epson.mobilephone.common.wifidirect.WiFiDirectManager;
  4. import com.evernote.edam.limits.Constants;
  5. import epson.common.ExternalFileUtils;
  6. import epson.print.CommonDefine;
  7. import java.io.BufferedReader;
  8. import java.io.File;
  9. import java.io.FileInputStream;
  10. import java.io.FileNotFoundException;
  11. import java.io.FileOutputStream;
  12. import java.io.IOException;
  13. import java.io.InputStreamReader;
  14. import java.net.MalformedURLException;
  15. import java.net.URL;
  16. import java.net.URLConnection;
  17. public final class MyUtility {
  18. public static File createTempFile(Context context, String str, String str2) throws IOException {
  19. if (str2.indexOf(CommonDefine.SLASH) != -1 || str2.indexOf("\\") != -1) {
  20. return null;
  21. }
  22. File file = new File(ExternalFileUtils.getInstance(context).getScannedImageDir(), str2);
  23. try {
  24. FileInputStream fileInputStream = new FileInputStream(new File(str));
  25. FileOutputStream fileOutputStream = new FileOutputStream(file);
  26. byte[] bArr = new byte[1024];
  27. while (true) {
  28. int read = fileInputStream.read(bArr);
  29. if (read > 0) {
  30. fileOutputStream.write(bArr, 0, read);
  31. } else {
  32. fileInputStream.close();
  33. fileOutputStream.close();
  34. return file;
  35. }
  36. }
  37. }
  38. }
  39. public static void copy(java.io.File r3, java.io.File r4) throws java.io.IOException {
  40. throw new UnsupportedOperationException("Method not decompiled: epson.server.utils.MyUtility.copy(java.io.File, java.io.File):void");
  41. }
  42. public static void createFolder(String str) {
  43. File file = new File(str);
  44. if (!file.exists()) {
  45. file.mkdirs();
  46. }
  47. }
  48. public static double mathRound(double d, int i) {
  49. if (i <= 0) {
  50. return 0.0d;
  51. }
  52. int i2 = 1;
  53. for (int i3 = 0; i3 < i; i3++) {
  54. i2 *= 10;
  55. }
  56. double d2 = i2;
  57. return (Math.round(d * d2)) / d2;
  58. }
  59. public String doNet(Context context) {
  60. String str = "";
  61. WiFiDirectManager.setPriorityToSimpleAP(context, false);
  62. try {
  63. URLConnection openConnection = new URL("https://support.epson.net/healthcheck/iPrint.html").openConnection();
  64. openConnection.setConnectTimeout(Constants.EDAM_BUSINESS_NOTEBOOKS_MAX);
  65. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(openConnection.getInputStream()));
  66. while (true) {
  67. String readLine = bufferedReader.readLine();
  68. if (readLine == null) {
  69. return str;
  70. }
  71. str = str + readLine;
  72. }
  73. } catch (MalformedURLException unused) {
  74. return str;
  75. } catch (IOException unused2) {
  76. return str;
  77. }
  78. }
  79. }