本文整理汇总了Java中org.eclipse.xtext.util.RuntimeIOException类的典型用法代码示例。如果您正苦于以下问题:Java RuntimeIOException类的具体用法?Java RuntimeIOException怎么用?Java RuntimeIOException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeIOException类属于org.eclipse.xtext.util包,在下文中一共展示了RuntimeIOException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
@Override
public void generateFile(String fileName, String outputConfigName, CharSequence contents) throws RuntimeIOException {
File file = getFile(fileName, outputConfigName);
if (!getOutputConfig(outputConfigName).isOverrideExistingResources() && file.exists()) {
return;
}
try {
createFolder(file.getParentFile());
String encoding = getEncoding(getURI(fileName, outputConfigName));
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), encoding);
try {
writer.append(postProcess(fileName, outputConfigName, contents, encoding));
if(callBack != null)
callBack.fileAdded(file);
if (writeTrace)
generateTrace(fileName, outputConfigName, contents);
} finally {
writer.close();
}
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
示例2: readBinaryFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
@Override
public InputStream readBinaryFile(final String fileName, final String outputCfgName) throws RuntimeIOException {
try {
try {
final URI uri = this.getURI(fileName, outputCfgName);
final InputStream input = this.converter.createInputStream(uri);
return this.beforeRead.beforeRead(uri, input);
} catch (final Throwable _t) {
if (_t instanceof FileNotFoundException) {
final FileNotFoundException e = (FileNotFoundException)_t;
throw new RuntimeIOException(e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例3: createTempDir
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
protected File createTempDir() {
if (temporaryFolder != null && temporaryFolder.isInitialized()) {
try {
return temporaryFolder.newFolder();
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
return com.google.common.io.Files.createTempDir();
}
示例4: readBinaryFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* @since 2.4
*/
@Override
public InputStream readBinaryFile(String fileName, String outputCfgName) throws RuntimeIOException {
File file = getFile(fileName, outputCfgName);
try {
return new BufferedInputStream(new FileInputStream(file));
} catch (FileNotFoundException e) {
throw new RuntimeIOException(e);
}
}
示例5: generateFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* @since 2.4
*/
@Override
public void generateFile(String fileName, String outputCfgName, InputStream content) {
try {
try {
byte[] byteArray = ByteStreams.toByteArray(content);
files.put(getFileName(fileName, outputCfgName), byteArray);
} finally {
content.close();
}
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
示例6: readBinaryFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* @since 2.4
*/
@Override
public InputStream readBinaryFile(String fileName, String outputCfgName) throws RuntimeIOException {
String name = getFileName(fileName, outputCfgName);
Object contents = files.get(name);
if (contents == null)
throw new RuntimeIOException("File not found: " + name);
if (contents instanceof byte[])
return new ByteArrayInputStream((byte[]) contents);
if (contents instanceof CharSequence)
return new StringInputStream(contents.toString());
throw new RuntimeIOException("Unknown File Data Type: " + contents.getClass() + " File: " + name);
}
示例7: readTextFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* @since 2.4
*/
@Override
public CharSequence readTextFile(String fileName, String outputCfgName) throws RuntimeIOException {
String name = getFileName(fileName, outputCfgName);
Object contents = files.get(name);
if (contents == null)
throw new RuntimeIOException("File not found: " + name);
if (contents instanceof CharSequence)
return (CharSequence) contents;
if (contents instanceof byte[])
throw new RuntimeIOException("Can not read a binary file using readTextFile(). File: " + name);
throw new RuntimeIOException("Unknown File Data Type: " + contents.getClass() + " File: " + name);
}
示例8: internalGetResourceDescription
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
@Override
protected IResourceDescription internalGetResourceDescription(final Resource resource,
IDefaultResourceDescriptionStrategy strategy) {
if (resource instanceof DerivedStateAwareResource) {
DerivedStateAwareResource res = (DerivedStateAwareResource) resource;
if (!res.isLoaded()) {
try {
res.load(res.getResourceSet().getLoadOptions());
} catch (IOException e) {
throw new RuntimeIOException(e);
}
}
boolean isInitialized = res.fullyInitialized || res.isInitializing;
try {
if (!isInitialized) {
res.eSetDeliver(false);
res.installDerivedState(true);
}
IResourceDescription description = createResourceDescription(resource, strategy);
if (!isInitialized) {
// eager initialize
for (IEObjectDescription desc : description.getExportedObjects()) {
desc.getEObjectURI();
}
}
return description;
} finally {
if (!isInitialized) {
if (log.isDebugEnabled())
log.debug("Discarding inferred state for "+resource.getURI());
res.discardDerivedState();
res.eSetDeliver(true);
}
}
} else {
if (log.isDebugEnabled())
log.debug("Invalid configuration. DerivedStateAwareResourceDescriptionManager was registered, but resource was a " + resource.getClass().getName());
return super.internalGetResourceDescription(resource, strategy);
}
}
示例9: generateFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
@Override
public void generateFile(final String fileName, final String outputCfgName, final InputStream content) throws RuntimeIOException {
try {
final URI uri = this.getURI(fileName, outputCfgName);
final OutputStream out = this.converter.createOutputStream(uri);
try {
final InputStream processedContent = this.beforeWrite.beforeWrite(uri, outputCfgName, content);
ByteStreams.copy(processedContent, out);
} finally {
out.close();
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例10: readTextFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
@Override
public CharSequence readTextFile(final String fileName, final String outputCfgName) throws RuntimeIOException {
try {
final URI uri = this.getURI(fileName, outputCfgName);
final InputStream inputstream = this.readBinaryFile(fileName, outputCfgName);
String _encoding = this.getEncoding(uri);
InputStreamReader _inputStreamReader = new InputStreamReader(inputstream, _encoding);
return CharStreams.toString(_inputStreamReader);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例11: createFolder
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
protected void createFolder(File parent) {
if (parent != null && !parent.mkdirs() && !parent.isDirectory())
throw new RuntimeIOException("Could not create directory " + parent);
}
示例12: isFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean isFile(String path, String outputConfigurationName) throws RuntimeIOException {
File file = getFile(path, outputConfigurationName);
return file!=null && file.exists() && file.isFile();
}
示例13: isFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* @since 2.9
*/
@Override
public boolean isFile(String path) throws RuntimeIOException {
return isFile(path, DEFAULT_OUTPUT);
}
示例14: isFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* Tests whether the file exists at the location denoted by the output configuration.
* Returns {@code true} if the file at the described location exists and is a normal file
* (not a directory). Otherwise {@code false}.
*
* @param path using '/' as path separator
* @param outputConfigurationName the name of the output configuration
* @return <code>true</code> when the file at the given path exists and is a normal file. Will return <code>false</code> when
* the path belongs to a directory.
*/
boolean isFile (String path, String outputConfigurationName) throws RuntimeIOException;
示例15: generateFile
import org.eclipse.xtext.util.RuntimeIOException; //导入依赖的package包/类
/**
* Writes binary data to disk. For writing text, it is recommended to use
* {@link IFileSystemAccess#generateFile(String, String, CharSequence)}
*/
void generateFile(String fileName, String outputCfgName, InputStream content) throws RuntimeIOException;