Java Code Examples for com.intellij.util.io.IOUtil#readString()
The following examples show how to use
com.intellij.util.io.IOUtil#readString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileUtil.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 6 votes |
public static String getParams(VirtualFile file) { String userData = file.getUserData(MY_KEY); if (userData != null) { return userData; } if (!(file instanceof NewVirtualFile)) { return "{}"; } try (DataInputStream is = QUERY_PARAMS_FILE_ATTRIBUTE.readAttribute(file)) { if (is == null || is.available() <= 0) { return "{}"; } String attributeData = IOUtil.readString(is); if (attributeData == null) { return "{}"; } else { file.putUserData(MY_KEY, attributeData); return attributeData; } } catch (IOException e) { return "{}"; } }
Example 2
Source File: ForcedBuildFileAttribute.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static String getFrameworkIdOfBuildFile(VirtualFile file) { if (file instanceof NewVirtualFile) { final DataInputStream is = FRAMEWORK_FILE_ATTRIBUTE.readAttribute(file); if (is != null) { try { try { if (is.available() == 0) { return null; } return IOUtil.readString(is); } finally { is.close(); } } catch (IOException e) { LOG.error(file.getPath(), e); } } return ""; } return file.getUserData(FRAMEWORK_FILE_MARKER); }
Example 3
Source File: Util.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public static long getModificationStamp(VirtualFile file) { long ret = -1; Long temporary = file.getUserData(Util.MODIFICATION_DATE_KEY); if(temporary == null || temporary <= 0) { if(file instanceof NewVirtualFile) { final DataInputStream is = MODIFICATION_STAMP_FILE_ATTRIBUTE.readAttribute(file); if(is != null) { try { try { if(is.available() > 0) { String value = IOUtil.readString(is); ret = convertToLong(value, ret); if(ret > 0) { file.putUserData(Util.MODIFICATION_DATE_KEY, ret); } } } finally { is.close(); } } catch(IOException e) { // Ignore it but we might need to throw an exception String message = e.getMessage(); } } } } else { ret = temporary; } return ret; }
Example 4
Source File: CopyingCompiler.java From consulo with Apache License 2.0 | 4 votes |
@Override public ValidityState createValidityState(DataInput in) throws IOException { return new DestinationFileInfo(IOUtil.readString(in), true); }
Example 5
Source File: GenericCompilerPersistentData.java From consulo with Apache License 2.0 | 4 votes |
public GenericCompilerPersistentData(File cacheStoreDirectory, int compilerVersion) throws IOException { myCompilerVersion = compilerVersion; myFile = new File(cacheStoreDirectory, "info"); if (!myFile.exists()) { LOG.info("Compiler info file doesn't exists: " + myFile.getAbsolutePath()); myVersionChanged = true; return; } try { DataInputStream input = new DataInputStream(new BufferedInputStream(new FileInputStream(myFile))); try { final int dataVersion = input.readInt(); if (dataVersion != VERSION) { LOG.info("Version of compiler info file (" + myFile.getAbsolutePath() + ") changed: " + dataVersion + " -> " + VERSION); myVersionChanged = true; return; } final int savedCompilerVersion = input.readInt(); if (savedCompilerVersion != compilerVersion) { LOG.info("Compiler caches version changed (" + myFile.getAbsolutePath() + "): " + savedCompilerVersion + " -> " + compilerVersion); myVersionChanged = true; return; } int size = input.readInt(); while (size-- > 0) { final String target = IOUtil.readString(input); final int id = input.readInt(); myTarget2Id.put(target, id); myUsedIds.add(id); } } finally { input.close(); } } catch (IOException e) { FileUtil.delete(myFile); throw e; } }