Create a {@link SameDiff}
instance from a file.
The method to save the file is
{@link #asFlatFile(File)}
@param file the file to load from
@return the loaded same diff instance
@throws IOException
426396
public static SameDiff fromFlatFile(@NonNull File file) throws IOException {
        byte[] bytes;
        try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
            bytes = IOUtils.toByteArray(is);
        }

        ByteBuffer bbIn = ByteBuffer.wrap(bytes);
        return fromFlatBuffers(bbIn);
    }
351365
public File write(File file) throws IOException {
        try (FileOutputStream fos = new FileOutputStream(file)) {
            write(fos);
            return file;
        }
    }
593180
protected byte[] loadBinaryFile(String file) throws IOException {
        try (InputStream is = resource.getInputStream(file)) {
            return IOUtils.toByteArray(is);
        }
    }
390997
public static InputStream asInputStream(File file) throws IOException {
		Validate.notNull(file, "file is null");
		return asInputStream(file.toPath());
	}
1092782
public static void copy(File file, OutputStream out) throws IOException {
    FileInputStream in = new FileInputStream(file);
    try {
      IOUtils.copy(new BufferedInputStream(in), out);
    }
    finally {
      IOUtils.closeQuietly(in);
    }
  }
921985
static public IParserInput getInstance(final File file) throws IOException
    {
        final List<String> args = new ArrayList<>();
        try (BufferedReader reader = new BufferedReader(new FileReader(file)))
        {
            String aConfigLine = null;
            while ((aConfigLine = reader.readLine()) != null)
                if (aConfigLine.length() > 0 && aConfigLine.charAt(0) != '#')
                    args.add(aConfigLine);
        }

        final NamespaceParser parser = new NamespaceParser();
        parser.args = args.toArray(new String[args.size()]);
        return parser;
    }
284570
public void saveAs(final File file) throws IOException {
        try {
            final FileOutputStream out = new FileOutputStream(file);
            try {
                this.save(out);
            } finally {
                out.flush();
                out.close();
            }
        } catch (final FileNotFoundException e) {
            this.logger.log(Level.SEVERE, "Can't open " + file, e);
            throw new IOException(e);
        } catch (final NullPointerException e) {
            this.logger.log(Level.SEVERE, "No file", e);
            throw new IOException(e);
        }
    }
459497
public static InputStream openFile(File file) throws RuntimeIOException {
    try {
      InputStream is = new BufferedInputStream(new FileInputStream(file));
      if (file.getName().endsWith(".gz")) {
        is = new GZIPInputStream(is);
      }
      return is;
    } catch (Exception e) {
      throw new RuntimeIOException(e);
    }
  }
63376
public JavaFileObject asJavaFileObject(File file) {
        JavacFileManager fm = (JavacFileManager)context.get(JavaFileManager.class);
        return fm.getRegularFile(file);
    }
540040
public static String readFile(File file) {
		FileInputStream inputStream;
		try {
			inputStream = new FileInputStream(file);
			return new String(readStream(inputStream));
		} catch (FileNotFoundException e) {
			JK.throww(e);
			return null;
		}
	}
654322
protected void createNewFile(final File file) {
        try {
            file.createNewFile();
            setFileNotWorldReadablePermissions(file);
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }
855763
public static InputStream openFromFile(final File file) {
    try {
      InputStream is = new BufferedInputStream(new FileInputStream(file),
          BUFFER_SIZE);
      if (file.getName().endsWith(".gz") || file.getName().endsWith("gz")) {
        is = new GZIPInputStream(is, BUFFER_SIZE);
      }
      return is;
    } catch (final IOException e) {
      throw new TerminateToolException(-1,
          "File '" + file + "' cannot be found", e);
    }
  }
31781
public static BlockInfoEx newInstance(File file) {
        BlockInfoEx blockInfo = new BlockInfoEx();
        blockInfo.logFile = file;

        BufferedReader reader = null;
        try {
            InputStreamReader in = new InputStreamReader(new FileInputStream(file), "UTF-8");

            reader = new BufferedReader(in);
            for (String line = reader.readLine(); line != null; line = reader.readLine()) {
                if (line.startsWith(KEY_QUA)) {
                    blockInfo.qualifier = line.split(KV)[1];
                } else if (line.startsWith(KEY_MODEL)) {
                    blockInfo.model = line.split(KV)[1];
                } else if (line.startsWith(KEY_API)) {
                    blockInfo.apiLevel = line.split(KV)[1];
                } else if (line.startsWith(KEY_IMEI)) {
                    blockInfo.imei = line.split(KV)[1];
                } else if (line.startsWith(KEY_CPU_CORE)) {
                    blockInfo.cpuCoreNum = Integer.valueOf(line.split(KV)[1]);
                } else if (line.startsWith(KEY_UID)) {
                    blockInfo.uid = line.split(KV)[1];
                } else if (line.startsWith(KEY_TIME_COST_START)) {
                    blockInfo.timeStart = line.split(KV)[1];
                } else if (line.startsWith(KEY_TIME_COST_END)) {
                    blockInfo.timeEnd = line.split(KV)[1];
                } else if (line.startsWith(KEY_TIME_COST)) {
                    blockInfo.timeCost = Long.valueOf(line.split(KV)[1]);
                } else if (line.startsWith(KEY_THREAD_TIME_COST)) {
                    blockInfo.threadTimeCost = Long.valueOf(line.split(KV)[1]);
                } else if (line.startsWith(KEY_PROCESS)) {
                    blockInfo.processName = line.split(KV)[1];
                } else if (line.startsWith(KEY_VERSION_NAME)) {
                    blockInfo.versionName = line.split(KV)[1];
                } else if (line.startsWith(KEY_VERSION_CODE)) {
                    blockInfo.versionCode = Integer.valueOf(line.split(KV)[1]);
                } else if (line.startsWith(KEY_NETWORK)) {
                    blockInfo.network = line.split(KV)[1];
                } else if (line.startsWith(KEY_TOTAL_MEMORY)) {
                    blockInfo.totalMemory = line.split(KV)[1];
                } else if (line.startsWith(KEY_FREE_MEMORY)) {
                    blockInfo.freeMemory = line.split(KV)[1];
                } else if (line.startsWith(KEY_CPU_BUSY)) {
                    blockInfo.cpuBusy = Boolean.valueOf(line.split(KV)[1]);
                } else if (line.startsWith(KEY_CPU_RATE)) {
                    String[] split = line.split(KV);
                    if (split.length > 1) {
                        StringBuilder cpuRateSb = new StringBuilder(split[1]);
                        cpuRateSb.append(line.split(KV)[1]).append(SEPARATOR);
                        line = reader.readLine();

                        // read until SEPARATOR appears
                        while (line != null) {
                            if (!line.equals("")) {
                                cpuRateSb.append(line).append(SEPARATOR);
                            } else {
                                break;
                            }
                            line = reader.readLine();
                        }
                        blockInfo.cpuRateInfo = cpuRateSb.toString();
                    }
                } else if (line.startsWith(KEY_STACK)) {
                    StringBuilder stackSb = new StringBuilder(line.split(KV)[1]);
                    line = reader.readLine();

                    // read until file ends
                    while (line != null) {
                        if (!line.equals("")) {
                            stackSb.append(line).append(SEPARATOR);
                        } else if (stackSb.length() > 0) {
                            // ignore continual blank lines
                            blockInfo.threadStackEntries.add(stackSb.toString());
                            stackSb = new StringBuilder();
                        }
                        line = reader.readLine();
                    }
                }
            }
            reader.close();
            reader = null;
        } catch (Throwable t) {
            Log.e(TAG, NEW_INSTANCE_METHOD, t);
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (Exception e) {
                Log.e(TAG, NEW_INSTANCE_METHOD, e);
            }
        }
        blockInfo.flushString();
        return blockInfo;
    }
1246359
public static File touch(File file) throws IORuntimeException {
		if (null == file) {
			return null;
		}
		if (false == file.exists()) {
			mkParentDirs(file);
			try {
				file.createNewFile();
			} catch (Exception e) {
				throw new IORuntimeException(e);
			}
		}
		return file;
	}
1074599
public static String fromFile(File file) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(file));
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
            sb.append(line);
            line = br.readLine();
            if (line != null)
                sb.append(System.lineSeparator());
        }

        br.close();
        return sb.toString();
    }
1299257
public static CacheConfiguration build(File file) throws IOException {
		ConfigMap<String, String> config = ConfigMap.load(file);
		return CacheConfiguration.build(config);
	}
1327252
public static <T> T deserialize(String file, Class<T> clazz) throws IOException, ClassNotFoundException {
        return TypeUtils.castToJavaBean(deserialize(file), clazz);
    }