本文整理汇总了Java中com.intellij.util.io.IOUtil类的典型用法代码示例。如果您正苦于以下问题:Java IOUtil类的具体用法?Java IOUtil怎么用?Java IOUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IOUtil类属于com.intellij.util.io包,在下文中一共展示了IOUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public void save(DataOutput out) throws IOException {
lockData();
try {
out.writeInt(myDeletedPaths.size());
for (String path : myDeletedPaths) {
IOUtil.writeString(path, out);
}
out.writeInt(myFilesToRecompile.size());
for (Map.Entry<BuildRootDescriptor, Set<File>> entry : myFilesToRecompile.entrySet()) {
IOUtil.writeString(entry.getKey().getRootId(), out);
final Set<File> files = entry.getValue();
out.writeInt(files.size());
for (File file : files) {
IOUtil.writeString(FileUtil.toSystemIndependentName(file.getPath()), out);
}
}
}
finally {
unlockData();
}
}
示例2: load
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public void load(DataInputStream in, JpsModel model, final BuildRootIndex buildRootIndex) throws IOException {
final TargetTypeRegistry registry = TargetTypeRegistry.getInstance();
int typeCount = in.readInt();
while (typeCount-- > 0) {
final String typeId = IOUtil.readString(in);
int targetCount = in.readInt();
BuildTargetType<?> type = registry.getTargetType(typeId);
BuildTargetLoader<?> loader = type != null ? type.createLoader(model) : null;
while (targetCount-- > 0) {
final String id = IOUtil.readString(in);
boolean loaded = false;
if (loader != null) {
BuildTarget<?> target = loader.createTarget(id);
if (target != null) {
getDelta(target).load(in, target, buildRootIndex);
myInitialScanPerformed.add(target);
loaded = true;
}
}
if (!loaded) {
LOG.info("Skipping unknown target (typeId=" + typeId + ", type=" + type + ", id=" + id + ")");
FilesDelta.skip(in);
}
}
}
}
示例3: save
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public synchronized void save() {
try {
FileUtil.createParentDirs(myTargetsFile);
DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myTargetsFile)));
try {
output.writeInt(0);
output.writeInt(myTargetIds.size());
for (Map.Entry<BuildTarget<?>, Integer> entry : myTargetIds.entrySet()) {
IOUtil.writeString(entry.getKey().getId(), output);
output.writeInt(entry.getValue());
}
}
finally {
output.close();
}
}
catch (IOException e) {
LOG.info("Cannot save " + myTargetType.getTypeId() + " targets data: " + e.getMessage(), e);
}
}
示例4: testReplaceWithEqualButNotSameKey
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public void testReplaceWithEqualButNotSameKey() throws IOException {
File file = FileUtil.createTempFile(getTestDirectoryName(), null);
ObjectObjectPersistentMultiMaplet<String, IntValueStreamable> maplet =
new ObjectObjectPersistentMultiMaplet<String, IntValueStreamable>(file, new CaseInsensitiveEnumeratorStringDescriptor(),
new IntValueExternalizer(),
COLLECTION_FACTORY);
try {
maplet.put("a", new IntValueStreamable(1));
assertEquals(1, assertOneElement(maplet.get("a")).value);
maplet.replace("A", Collections.singletonList(new IntValueStreamable(2)));
assertEquals(2, assertOneElement(maplet.get("a")).value);
} finally {
maplet.close();
IOUtil.deleteAllFilesStartingWith(file);
}
}
示例5: save
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public void save() throws IOException {
final DataOutputStream output = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile)));
try {
output.writeInt(VERSION);
output.writeInt(myCompilerVersion);
output.writeInt(myTarget2Id.size());
for (Map.Entry<String, Integer> entry : myTarget2Id.entrySet()) {
IOUtil.writeString(entry.getKey(), output);
output.writeInt(entry.getValue());
}
}
finally {
output.close();
}
}
示例6: VcsLogHashMapImpl
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public VcsLogHashMapImpl(@NotNull Project project, @NotNull Map<VirtualFile, VcsLogProvider> logProviders) throws IOException {
cleanupOldNaming(project, logProviders);
String logId = calcLogId(project, logProviders);
final File mapFile = new File(LOG_CACHE_APP_DIR, logId + "." + VERSION);
if (!mapFile.exists()) {
IOUtil.deleteAllFilesStartingWith(new File(LOG_CACHE_APP_DIR, logId));
}
Disposer.register(project, this);
myPersistentEnumerator = IOUtil.openCleanOrResetBroken(new ThrowableComputable<PersistentEnumerator<Hash>, IOException>() {
@Override
public PersistentEnumerator<Hash> compute() throws IOException {
return new PersistentEnumerator<Hash>(mapFile, new MyHashKeyDescriptor(), Page.PAGE_SIZE);
}
}, mapFile);
}
示例7: getFrameworkIdOfBuildFile
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
@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);
}
示例8: forceBuildFile
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
private static void forceBuildFile(VirtualFile file, @Nullable String value) {
if (file instanceof NewVirtualFile) {
final DataOutputStream os = FRAMEWORK_FILE_ATTRIBUTE.writeAttribute(file);
try {
try {
IOUtil.writeString(StringUtil.notNullize(value), os);
}
finally {
os.close();
}
}
catch (IOException e) {
LOG.error(e);
}
}
else {
file.putUserData(FRAMEWORK_FILE_MARKER, value);
}
}
示例9: internParts
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
@Nullable
protected SubstringWrapper[] internParts(String path, boolean forAddition) {
int start = 0;
boolean asBytes = forAddition && IOUtil.isAscii(path);
List<SubstringWrapper> key = new ArrayList<SubstringWrapper>();
SubstringWrapper flyweightKey = new SubstringWrapper();
while (start < path.length()) {
flyweightKey.findSubStringUntilNextSeparator(path, start);
SubstringWrapper interned = myInternMap.get(flyweightKey);
if (interned == null) {
if (!forAddition) {
return null;
}
myInternMap.add(interned = flyweightKey.createPersistentCopy(asBytes));
}
key.add(interned);
start += flyweightKey.len;
}
return key.toArray(new SubstringWrapper[key.size()]);
}
示例10: thingsWentWrongLetsReinitialize
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
private void thingsWentWrongLetsReinitialize(IOException e) {
try {
if (myMap != null) {
try {
myMap.close();
}
catch (IOException ignore) {
}
IOUtil.deleteAllFilesStartingWith(myFile);
}
myMap = initializeMap();
LOG.error("Repaired after crash", e);
}
catch (IOException e1) {
LOG.error("Cannot repair", e1);
myMap = null;
}
}
示例11: getValueExternalizer
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
@NotNull
@Override
public DataExternalizer<XsdNamespaceBuilder> getValueExternalizer() {
return new DataExternalizer<XsdNamespaceBuilder>() {
@Override
public void save(@NotNull DataOutput out, XsdNamespaceBuilder value) throws IOException {
IOUtil.writeUTF(out, value.getNamespace() == null ? "" : value.getNamespace());
IOUtil.writeUTF(out, value.getVersion() == null ? "" : value.getVersion());
writeList(out, value.getTags());
writeList(out, value.getRootTags());
}
@Override
public XsdNamespaceBuilder read(@NotNull DataInput in) throws IOException {
return new XsdNamespaceBuilder(IOUtil.readUTF(in),
IOUtil.readUTF(in),
readList(in),
readList(in));
}
};
}
示例12: read
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
@Nullable
@Override
public Set<MyResourceInfo> read(@NotNull DataInput in) throws IOException {
final int size = DataInputOutputUtil.readINT(in);
if (size < 0 || size > 65535) {
// Something is very wrong; trigger an index rebuild
throw new IOException("Corrupt Index: Size " + size);
}
if (size == 0) {
return Collections.emptySet();
}
final Set<MyResourceInfo> result = Sets.newHashSetWithExpectedSize(size);
for (int i = 0; i < size; i++) {
final String type = IOUtil.readUTF(in);
final String name = IOUtil.readUTF(in);
final String context = IOUtil.readUTF(in);
final int offset = DataInputOutputUtil.readINT(in);
result.add(new MyResourceInfo(new ResourceEntry(type, name, context), offset));
}
return result;
}
示例13: visitFile
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
@Override
public boolean visitFile(VirtualFile file) {
file.putUserData(MODIFICATION_DATE_KEY, null);
if(file instanceof NewVirtualFile) {
final DataOutputStream os = MODIFICATION_STAMP_FILE_ATTRIBUTE.writeAttribute(file);
try {
try {
IOUtil.writeString(StringUtil.notNullize("0"), os);
} finally {
os.close();
}
} catch(IOException e) {
// Ignore it but we might need to throw an exception
String message = e.getMessage();
}
}
return recursive;
}
示例14: setModificationStamp
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public static void setModificationStamp(VirtualFile file) {
// Store it in memory first
if(file != null) {
file.putUserData(Util.MODIFICATION_DATE_KEY, file.getTimeStamp());
if(file instanceof NewVirtualFile) {
final DataOutputStream os = MODIFICATION_STAMP_FILE_ATTRIBUTE.writeAttribute(file);
try {
try {
IOUtil.writeString(StringUtil.notNullize(file.getTimeStamp() + ""), os);
} finally {
os.close();
}
} catch(IOException e) {
// Ignore it but we might need to throw an exception
String message = e.getMessage();
}
}
}
}
示例15: save
import com.intellij.util.io.IOUtil; //导入依赖的package包/类
public void save(DataOutput out) throws IOException {
out.writeInt(myDeletedPaths.size());
synchronized (myDeletedPaths) {
for (String path : myDeletedPaths) {
IOUtil.writeString(path, out);
}
}
synchronized (myFilesToRecompile) {
out.writeInt(myFilesToRecompile.size());
for (Map.Entry<BuildRootDescriptor, Set<File>> entry : myFilesToRecompile.entrySet()) {
IOUtil.writeString(entry.getKey().getRootId(), out);
final Set<File> files = entry.getValue();
out.writeInt(files.size());
for (File file : files) {
IOUtil.writeString(FileUtil.toSystemIndependentName(file.getPath()), out);
}
}
}
}