@Override public String asText(String encoding) throws IOException { return delegate.asText(encoding); }
@Override public String asText() throws IOException { return delegate.asText(); }
/** Reads the full content of the file object and returns it as string. * This is similar to calling {@link #asText(java.lang.String)} with * default system encoding. * * @return string representing the content of the file * @exception IOException in case the content cannot be fully read * @since 7.21 */ public String asText() throws IOException { return asText(Charset.defaultCharset().name()); }
static MIMEResolver forDescriptor(FileObject fo, boolean warn) { if (warn && !isUserDefined(fo)) { ERR.log(Level.WARNING, "Ineffective registration of resolver {0} use @MIMEResolver.Registration! See bug #191777.", fo.getPath()); if (ERR.isLoggable(Level.FINE)) { try { ERR.fine(fo.asText()); } catch (IOException ex) { ERR.log(Level.FINE, null, ex); } } } return new Impl(fo); }
private String getContents() { try { return stripBOM(getPrimaryFile().asText(charset.name())); } catch (IOException ex) { Exceptions.printStackTrace(ex); return null; } }
@Messages({ "# {0} - name of license", "ERR_missing_license_template=<License header template not found for name \"{0}\">"}) private void setTextToGlobalLicense() { GlobalItem item = (GlobalItem) comGlobal.getSelectedItem(); if (item == null) { epLicense.setText(""); } else { try { if (item.fileObject != null) { epLicense.setText(item.fileObject.asText()); } else { epLicense.setText(ERR_missing_license_template(item.getName())); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }
/** * * @param url * @param content * @return a non-negative line shift of content of 'url' in 'content', or -1 * when content of 'url' is not a subset of 'content'. */ static int getContentLineShift(URL url, String content) { String origContent; FileObject fo = URLMapper.findFileObject(url); if (fo != null) { try { origContent = fo.asText(); } catch (IOException ex) { return 0; } } else { return 0; } int index = content.indexOf(origContent); if (index < 0) { return -1; } String prep = content.substring(0, index); return countNewLines(prep); }
FileObject fo = FileUtil.toFileObject(failedFile); if (fo != null) { return fo.asText();
@Override public void actionPerformed(ActionEvent e) { TopComponent tcArray[] = WindowManager.getDefault().findMode("editor").getTopComponents(); for (TopComponent tc : tcArray) { System.out.println("tc = " + tc); if (null != tc && null != tc.getDisplayName() && tc.getDisplayName().equals("test.java")) { Collection<? extends FileObject> fileobjs = tc.getLookup().lookupAll(FileObject.class); for (FileObject fo : fileobjs) { try { String text = fo.asText(); System.out.println("text = " + text); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } } } }
try { String testMethodName = getTestMethodName(methodName); if (fo != null && !fo.asText().replaceAll("\n", "").trim().contains(testMethodName.concat("("))) { //NOI18N framework2Add.add(framework);
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private String getFileBasedProperty (final @Nonnull String attribute) throws NotFoundException, IOException { log.trace("getFileBasedProperty({})", attribute); final FileObject attributeFile = file.getFileObject(attribute); if (attributeFile == null) { throw new NotFoundException(file.getPath() + "/" + attribute); } log.trace(">>>> reading from {}", attributeFile.getPath()); String text = attributeFile.asText(); // FIXME: this should be done in a specific postprocessor registered only for Content // FIXME: and do this with StringTemplate - remember to escape $'s in the source text = text.replaceAll("\\$media\\(([^\\)]*)\\)", site.getContextPath() + "/media/$1"); return text; }
@Messages({ "# {0} - path of license", "ERR_missing_license_path=File at path \"{0}\" doesn't exist."}) private void setTextToProjectLicense() { category.setErrorMessage(null); String path = txtProject.getText(); FileObject fo = handler.resolveProjectLocation(path); if (fo != null && fo.isData()) { try { epLicense.setText(fo.asText()); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } else { category.setErrorMessage(ERR_missing_license_path(path)); epLicense.setText(defaultProjectLicense); } }
public static TestSuite suite(Class<?> clazz, String filePattern) { NbTestSuite result = new NbTestSuite(); Pattern patt = Pattern.compile(filePattern); for (String test : listTests(clazz)) { if (!patt.matcher(test).matches()) { continue; } //TODO: URL testURL = clazz.getClassLoader().getResource(test); assertNotNull(testURL); FileObject testFO = URLMapper.findFileObject(testURL); assertNotNull(testFO); String hint = test.substring(0, test.length() - ".test".length()) + ".hint"; URL hintURL = clazz.getClassLoader().getResource(hint); assertNotNull(hintURL); FileObject hintFO = URLMapper.findFileObject(hintURL); assertNotNull(hintFO); try { for (TestCase tc : TestParser.parse(testFO.asText("UTF-8"))) { result.addTest(new DeclarativeHintsTestBase(hintFO, testFO, tc)); } } catch (IOException ex) { throw new IllegalStateException(ex); } } return result; }
boolean parameterized = false; try { String text = testFO.asText(); if (text != null) { text = text.replaceAll("\n", "").replaceAll(" ", "");
int lineStartOffset = LexerUtils.getLineBeginningOffset(modelSource, line); int column = offset-lineStartOffset; String sourceMapText = sourceMapFob.asText(); SourceMap sourceMap = SourceMap.parse(sourceMapText); final Mapping mapping = sourceMap.findMapping(line, column);
if (sourceMapFob != null) { try { String sourceMapText = sourceMapFob.asText(); SourceMap sourceMap = SourceMap.parse(sourceMapText); final Mapping mapping = sourceMap.findMapping(rule.getSourceLine());