List of usage examples for org.apache.commons.io.input BOMInputStream BOMInputStream
public BOMInputStream(InputStream delegate)
From source file:br.gov.lexml.parser.documentoarticulado.TestUtil.java
public static String sampleText(String resourceName) { try {//from w w w . j av a 2 s . c o m InputStream input = new BOMInputStream(TestUtil.class.getResourceAsStream(resourceName)); try { return IOUtils.toString(input, ENCODING); } finally { input.close(); } } catch (IOException e) { throw new IllegalArgumentException(e); } }
From source file:com.stevpet.sonar.plugins.dotnet.resharper.customseverities.FileCustomSeverities.java
/** * Create inputsource for a file/*from www . j ava 2 s . c o m*/ * Creates inputstream, removes BOM * @return null in case file could not be opened, otherwise inputsource for the file */ @Override InputSource createInputSource(String path) { try { LOG.trace("Using " + path); InputStream fileReader = new FileInputStream(path); InputStream inputStream = new BOMInputStream(fileReader); return new InputSource(inputStream); } catch (FileNotFoundException e) { LOG.error("could not open " + path + "defined in " + ReSharperConfiguration.CUSTOM_SEVERITIES_PATH + " reason:", e); } return null; }
From source file:com.wrightfully.sonar.plugins.dotnet.resharper.customseverities.FileCustomSeverities.java
/** * Create inputsource for a file/*from w ww. j av a 2 s . com*/ * Creates inputstream, removes BOM * @return null in case file could not be opened, otherwise inputsource for the file */ @Override InputSource createInputSource(String path) { try { LOG.trace("Using " + path); InputStream fileReader = new FileInputStream(path); InputStream inputStream = new BOMInputStream(fileReader); return new InputSource(inputStream); } catch (FileNotFoundException e) { LOG.error("could not open " + path + "defined in " + ReSharperConstants.CUSTOM_SEVERITIES_PATH + " reason:", e); } return null; }
From source file:gov.vha.isaac.loincTP.convert.LoincCsvFileReader.java
public LoincCsvFileReader(File f) throws IOException { System.out.println("Using the data file " + f.getAbsolutePath()); //Their new format includes the (optional) UTF-8 BOM, which chokes java for stupid legacy reasons. reader = new CSVReader( new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(f))))); header = readLine();/*from w ww .j ava2 s . com*/ readReleaseNotes(f.getParentFile()); }
From source file:de.uzk.hki.da.metadata.LidoMetadataStructure.java
public LidoMetadataStructure(Path workPath, File metadataFile, List<de.uzk.hki.da.model.Document> documents) throws FileNotFoundException, JDOMException, IOException { super(workPath, metadataFile, documents); lidoFile = metadataFile;// w ww . j a va 2 s . com currentDocuments = documents; SAXBuilder builder = XMLUtils.createNonvalidatingSaxBuilder(); FileInputStream fileInputStream = new FileInputStream(Path.makeFile(workPath, metadataFile.getPath())); BOMInputStream bomInputStream = new BOMInputStream(fileInputStream); Reader reader = new InputStreamReader(bomInputStream, "UTF-8"); InputSource is = new InputSource(reader); is.setEncoding("UTF-8"); doc = builder.build(is); lidoParser = new LidoParser(doc); lidoLinkResources = lidoParser.getLidoLinkResources(); fileInputStream.close(); bomInputStream.close(); }
From source file:com.apelon.akcds.loinc.CSVFileReader.java
public CSVFileReader(File f) throws IOException { ConsoleUtil.println("Using the data file " + f.getAbsolutePath()); //Their new format includes the (optional) UTF-8 BOM, which chokes java for stupid legacy reasons. reader = new CSVReader( new BufferedReader(new InputStreamReader(new BOMInputStream(new FileInputStream(f))))); header = readLine();//from w w w . j a va 2s.co m readReleaseNotes(f.getParentFile()); }
From source file:com.glue.feed.toulouse.open.data.venue.ToulouseEquipementsJob.java
@Override public void execute(JobExecutionContext arg0) throws JobExecutionException { try {//from w w w . j a v a2 s . c om URL url = new URL( "http://data.grandtoulouse.fr/web/guest/les-donnees/-/opendata/card/23851-equipements-culturels/resource/document?p_p_state=exclusive&_5_WAR_opendataportlet_jspPage=%2Fsearch%2Fview_card_license.jsp"); ZipInputStream zin = new ZipInputStream(url.openStream()); ZipEntry entry = GlueIOUtils.getEntry(zin, new FileExtensionFilter(".csv")); InputStream in = GlueIOUtils.getDeferredInputStream(zin, entry.getName()); BufferedReader reader = new BufferedReader( new InputStreamReader(new BOMInputStream(in), Charset.forName("UTF-8"))); CSVFeedParser<VenueBean> parser = new CSVFeedParser<>(reader, VenueBean.class); final FeedMessageListener<Venue> delegate = new VenueMessageListener(); final GlueObjectBuilder<VenueBean, Venue> venueBuilder = new VenueBeanVenueBuilder(); parser.setFeedMessageListener(new FeedMessageListener<VenueBean>() { @Override public void newMessage(VenueBean msg) throws Exception { Venue venue = venueBuilder.build(msg); delegate.newMessage(venue); } @Override public void close() throws IOException { delegate.close(); } }); parser.read(); parser.close(); LOG.info("Done"); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new JobExecutionException(e); } }
From source file:com.github.dannil.scbjavaclient.communication.http.HttpResponse.java
/** * <p>Retrieves the body for the current <code>InputStream</code>.</p> * * @return the body// w ww. j a va 2 s . co m */ public String getBody() { if (this.stream == null) { return null; } try (BOMInputStream bis = new BOMInputStream(this.stream)) { try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { for (int result = bis.read(); result != -1; result = bis.read()) { bos.write((byte) result); } return bos.toString(); } } catch (IOException e) { throw new SCBClientException(e); } }
From source file:com.github.riccardove.easyjasub.inputtextsub.InputTextSubFile.java
public InputTextSubFile(SubtitleFileType inputFormat, String fileName, InputStream is) throws InputTextSubException, IOException { try {/* w w w. ja v a 2 s .c om*/ tto = createFormat(inputFormat).parseFile(fileName, new BOMInputStream(is)); } catch (FatalParsingException ex) { throw new InputTextSubException("Parse error returned by subtitle read library", ex); } captions = new ArrayList<InputSubtitleLine>(tto.captions.size()); for (Caption caption : tto.captions.values()) { InputSubtitleLine line = new InputSubtitleLine(); line.setContent(caption.content); line.setStartTime(new SubtitleFileTimeWrapper(caption.start).getMSeconds()); line.setEndTime(new SubtitleFileTimeWrapper(caption.end).getMSeconds()); captions.add(line); } }
From source file:net.orzo.scripting.SourceCode.java
/** * Creates a source code object using contents of provided file. UTF-8 BOM * (if present) is automatically removed. * * @param f text file containing source code * @return source code containing contents of file f *///from w w w. j a v a 2 s . co m public static SourceCode fromFile(File f) throws IOException { try (BOMInputStream bis = new BOMInputStream(new FileInputStream(f))) { return new SourceCode(f.getAbsolutePath(), f.getName(), new String(ByteStreams.toByteArray(bis), "UTF-8")); } }