Java Code Examples for java.io.BufferedInputStream

The following examples show how to use java.io.BufferedInputStream. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 2
Source Project: FastAsyncWorldedit   Source File: MCAFile.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void streamChunk(byte[] data, RunnableVal<NBTStreamer> withStream) throws IOException {
    if (data != null) {
        try {
            FastByteArrayInputStream nbtIn = new FastByteArrayInputStream(data);
            FastByteArrayInputStream bais = new FastByteArrayInputStream(data);
            InflaterInputStream iis = new InflaterInputStream(bais, new Inflater(), 1);
            fieldBuf2.set(iis, byteStore2.get());
            BufferedInputStream bis = new BufferedInputStream(iis);
            NBTInputStream nis = new NBTInputStream(bis);
            fieldBuf3.set(nis, byteStore3.get());
            NBTStreamer streamer = new NBTStreamer(nis);
            withStream.run(streamer);
            streamer.readQuick();
        } catch (IllegalAccessException unlikely) {
            unlikely.printStackTrace();
        }
    }
}
 
Example 3
Source Project: Wikidata-Toolkit   Source File: DirectoryManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns an input stream that applies the required decompression to the
 * given input stream.
 *
 * @param inputStream
 *            the input stream with the (possibly compressed) data
 * @param compressionType
 *            the kind of compression
 * @return an input stream with decompressed data
 * @throws IOException
 *             if there was a problem creating the decompression streams
 */
protected InputStream getCompressorInputStream(InputStream inputStream,
		CompressionType compressionType) throws IOException {
	switch (compressionType) {
	case NONE:
		return inputStream;
	case GZIP:
		return new GZIPInputStream(inputStream);
	case BZ2:
		return new BZip2CompressorInputStream(new BufferedInputStream(
				inputStream));
	default:
		throw new IllegalArgumentException("Unsupported compression type: "
				+ compressionType);
	}
}
 
Example 4
public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException {
    FileInputStream fis = new FileInputStream(file); // throws IOException
    BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize);

    // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length
    long length = file.length();
    if (length > Integer.MAX_VALUE) {
        length = MidiFileFormat.UNKNOWN_LENGTH;
    }
    MidiFileFormat fileFormat = null;
    try {
        fileFormat = getMidiFileFormatFromStream(bis, (int) length, null);
    } finally {
        bis.close();
    }
    return fileFormat;
}
 
Example 5
Source Project: wind-im   Source File: FileUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static void writeResourceToFile(String resourceName, File file) throws FileNotFoundException, IOException {
	if (!file.exists()) {
		new FileOutputStream(file).close();
	}
	InputStream is = MysqlManager.class.getResourceAsStream(resourceName);
	BufferedInputStream bis = new BufferedInputStream(is);
	FileOutputStream fos = new FileOutputStream(file);
	try {
		byte[] buffer = new byte[1024];
		int bytesLen = 0;
		while ((bytesLen = bis.read(buffer)) != -1) {
			fos.write(buffer, 0, bytesLen);
		}
	} finally {
		if (bis != null) {
			bis.close();
		}
		if (is != null) {
			is.close();
		}
		if (fos != null) {
			fos.close();
		}
	}
}
 
Example 6
@Override
public InputStream getAsInputStream(String key)
{
    File dataFile = getDataFile(key);
    
    try
    {
        if (dataFile.exists())
            return new BufferedInputStream(new FileInputStream(dataFile));
    }
    catch (FileNotFoundException e)
    {
    }
    
    return null;
}
 
Example 7
Source Project: JReFrameworker   Source File: JarModifier.java    License: MIT License 6 votes vote down vote up
public byte[] extractEntry(String entry) throws IOException {
	JarInputStream zin = new JarInputStream(new BufferedInputStream(new FileInputStream(jarFile)));
	JarEntry currentEntry = null;
	while ((currentEntry = zin.getNextJarEntry()) != null) {
		if (currentEntry.getName().equals(entry)) {
			// currentEntry.getSize() may not be accurate, so read bytes into a stream first
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			byte[] buf = new byte[4096];
			while (true) {
				int n = zin.read(buf);
				if (n < 0){
					break;
				}
				baos.write(buf, 0, n);
			}
			zin.close();
			return baos.toByteArray();
		}
	}
	zin.close();
	return null;
}
 
Example 8
/**
 * @return null if we were unable to load the cached version
 */
public GrammaticalLabelSetImpl read() {
    // if we're tracking duplicated labels, we need to load the file directly in order to look at all the labels, so don't load from the cache
    if (this.language == LanguageProviderFactory.get().getBaseLanguage() && GrammaticalLabelFileParser.isDupeLabelTrackingEnabled()) {
        return null;
    }

    logger.info("Loading " + labelSetName + " from cache");
    long start = System.currentTimeMillis();
    try (ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream(this.cacheFile)))) {
        GrammaticalLabelSetImpl labelSet = (GrammaticalLabelSetImpl)ois.readObject();
        logger.info("Loaded " + this.labelSetName + " from cache in " + (System.currentTimeMillis() - start)
            + " ms");
        return labelSet;
    }
    catch (Exception e) {
        logger.log(Level.INFO, "Could not load " + labelSetName + " from cache: ", e);
        delete();
    }
    return null;
}
 
Example 9
Source Project: Bytecoder   Source File: StandardMidiFileReader.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public MidiFileFormat getMidiFileFormat(File file) throws InvalidMidiDataException, IOException {
    FileInputStream fis = new FileInputStream(file); // throws IOException
    BufferedInputStream bis = new BufferedInputStream(fis, bisBufferSize);

    // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length
    long length = file.length();
    if (length > Integer.MAX_VALUE) {
        length = MidiFileFormat.UNKNOWN_LENGTH;
    }
    MidiFileFormat fileFormat = null;
    try {
        fileFormat = getMidiFileFormatFromStream(bis, (int) length, null);
    } finally {
        bis.close();
    }
    return fileFormat;
}
 
Example 10
Source Project: JDKSourceCode1.8   Source File: FuncSystemProperty.java    License: MIT License 6 votes vote down vote up
/**
 * Retrieve a propery bundle from a specified file
 *
 * @param file The string name of the property file.  The name
 * should already be fully qualified as path/filename
 * @param target The target property bag the file will be placed into.
 */
public void loadPropertyFile(String file, Properties target)
{
  try
  {
    // Use SecuritySupport class to provide priveleged access to property file
    InputStream is = SecuritySupport.getResourceAsStream(ObjectFactory.findClassLoader(),
                                            file);

    // get a buffered version
    BufferedInputStream bis = new BufferedInputStream(is);

    target.load(bis);  // and load up the property bag from this
    bis.close();  // close out after reading
  }
  catch (Exception ex)
  {
    // ex.printStackTrace();
    throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(ex);
  }
}
 
Example 11
Source Project: fdroidclient   Source File: RepoDetails.java    License: GNU General Public License v3.0 6 votes vote down vote up
@NonNull
public static RepoDetails getFromFile(InputStream inputStream, int pushRequests) {
    try {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        SAXParser parser = factory.newSAXParser();
        XMLReader reader = parser.getXMLReader();
        RepoDetails repoDetails = new RepoDetails();
        MockRepo mockRepo = new MockRepo(100, pushRequests);
        RepoXMLHandler handler = new RepoXMLHandler(mockRepo, repoDetails);
        reader.setContentHandler(handler);
        InputSource is = new InputSource(new BufferedInputStream(inputStream));
        reader.parse(is);
        return repoDetails;
    } catch (ParserConfigurationException | SAXException | IOException e) {
        e.printStackTrace();
        fail();

        // Satisfies the compiler, but fail() will always throw a runtime exception so we never
        // reach this return statement.
        return null;
    }
}
 
Example 12
Source Project: netbeans   Source File: DocDownloader.java    License: Apache License 2.0 6 votes vote down vote up
@NonNull
public static Future<String> download(
        @NonNull final URL url,
        @NonNull final Callable<Boolean> cancel) {
    return RP.submit(()-> {
        if (cancel.call()) {
            return "";  //NOI18N
        }
        final ProgressHandle handle = ProgressHandle.createHandle(NbBundle.getMessage(DocDownloader.class, "LBL_DownloadingDoc"));
        handle.start();
        try {
            final ByteArrayOutputStream out = new ByteArrayOutputStream();
            try(BufferedInputStream in = new BufferedInputStream(url.openStream())) {
                FileUtil.copy(in, out);
            }
            return cancel.call() ?
                    ""  //NOI18N
                    : new String(out.toByteArray(),"UTF-8");  //NOI18N
        } finally {
            handle.finish();
        }
    });
}
 
Example 13
Source Project: jdk8u-dev-jdk   Source File: Main.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Given a file, find only the properties that are setable by AppletViewer.
 *
 * @param inFile A Properties file from which we select the properties of
 *             interest.
 * @return     A Properties object containing all of the AppletViewer
 *             user-specific properties.
 */
private Properties getAVProps(File inFile) {
    Properties avProps  = new Properties();

    // read the file
    Properties tmpProps = new Properties();
    try (FileInputStream in = new FileInputStream(inFile)) {
        tmpProps.load(new BufferedInputStream(in));
    } catch (IOException e) {
        System.err.println(lookup("main.err.prop.cantread", inFile.toString()));
    }

    // pick off the properties we care about
    for (int i = 0; i < avDefaultUserProps.length; i++) {
        String value = tmpProps.getProperty(avDefaultUserProps[i][0]);
        if (value != null) {
            // the property exists in the file, so replace the default
            avProps.setProperty(avDefaultUserProps[i][0], value);
        } else {
            // just use the default
            avProps.setProperty(avDefaultUserProps[i][0],
                                avDefaultUserProps[i][1]);
        }
    }
    return avProps;
}
 
Example 14
Source Project: ade   Source File: MainScorerImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public final IMainScorer load(File modelFile) throws IOException, AdeException {
    final ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(modelFile)));
    try {
        final MainScorerImpl res = (MainScorerImpl) in.readObject();
        final FlowTemplateFactory flow = Ade.getAde().getFlowFactory().getFlowByName(res.m_flowName);
        final Map<String, FramingFlowType> myFramingFlows = flow.getMyFramingFlows();
        res.m_framingFlow = myFramingFlows.get(flow.getUploadFramer());
        res.m_scorerSchemas = flow.getScorerSchemas();
        res.wakeUp();
        return res;
    } catch (ClassNotFoundException e) {
        throw new AdeUsageException("Failed loading model from file: " + modelFile.getAbsolutePath(), e);
    } finally {
        in.close();
    }
}
 
Example 15
Source Project: localization_nifi   Source File: ZooKeeperStateServer.java    License: Apache License 2.0 6 votes vote down vote up
public static ZooKeeperStateServer create(final NiFiProperties properties) throws IOException, ConfigException {
    final File propsFile = properties.getEmbeddedZooKeeperPropertiesFile();
    if (propsFile == null) {
        return null;
    }

    if (!propsFile.exists() || !propsFile.canRead()) {
        throw new IOException("Cannot create Embedded ZooKeeper Server because the Properties File " + propsFile.getAbsolutePath()
            + " referenced in nifi.properties does not exist or cannot be read");
    }

    final Properties zkProperties = new Properties();
    try (final InputStream fis = new FileInputStream(propsFile);
        final InputStream bis = new BufferedInputStream(fis)) {
        zkProperties.load(bis);
    }

    return new ZooKeeperStateServer(zkProperties);
}
 
Example 16
/**
 * A deserialized serialized queue has same elements in same order
 */
public void testSerialization() throws Exception {
    LinkedBlockingQueue q = populatedQueue(SIZE);

    ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
    ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
    out.writeObject(q);
    out.close();

    ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
    LinkedBlockingQueue r = (LinkedBlockingQueue)in.readObject();
    assertEquals(q.size(), r.size());
    while (!q.isEmpty())
        assertEquals(q.remove(), r.remove());
}
 
Example 17
Source Project: consulo   Source File: ArtifactCompilerUtil.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Pair<InputStream, Long> getArchiveEntryInputStream(VirtualFile sourceFile, final CompileContext context) throws IOException {
  final String fullPath = sourceFile.getPath();
  final int jarEnd = fullPath.indexOf(ArchiveFileSystem.ARCHIVE_SEPARATOR);
  LOG.assertTrue(jarEnd != -1, fullPath);
  String pathInJar = fullPath.substring(jarEnd + ArchiveFileSystem.ARCHIVE_SEPARATOR.length());
  String jarPath = fullPath.substring(0, jarEnd);
  final ZipFile jarFile = new ZipFile(new File(FileUtil.toSystemDependentName(jarPath)));
  final ZipEntry entry = jarFile.getEntry(pathInJar);
  if (entry == null) {
    context.addMessage(CompilerMessageCategory.ERROR, "Cannot extract '" + pathInJar + "' from '" + jarFile.getName() + "': entry not found", null, -1, -1);
    return Pair.empty();
  }

  BufferedInputStream bufferedInputStream = new BufferedInputStream(jarFile.getInputStream(entry)) {
    @Override
    public void close() throws IOException {
      super.close();
      jarFile.close();
    }
  };
  return Pair.<InputStream, Long>create(bufferedInputStream, entry.getSize());
}
 
Example 18
Source Project: xian   Source File: DefaultExhibitorRestClient.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String getRaw(String hostname, int port, String uriPath, String mimeType) throws Exception
{
    URI                 uri = new URI(useSsl ? "https" : "http", null, hostname, port, uriPath, null, null);
    HttpURLConnection   connection = (HttpURLConnection)uri.toURL().openConnection();
    connection.addRequestProperty("Accept", mimeType);
    StringBuilder       str = new StringBuilder();
    InputStream         in = new BufferedInputStream(connection.getInputStream());
    try
    {
        for(;;)
        {
            int     b = in.read();
            if ( b < 0 )
            {
                break;
            }
            str.append((char)(b & 0xff));
        }
    }
    finally
    {
        CloseableUtils.closeQuietly(in);
    }
    return str.toString();
}
 
Example 19
/**
 * Finds the corresponding byte position for the given UTF-8 character
 * position, starting from the byte position <code>startPos</code>.
 * See comments in SQLChar.readExternal for more notes on
 * processing the UTF8 format.
 *
 * @param charPos character position
 * @return Stream position in bytes for the given character position.
 * @throws EOFException if the character position specified is greater than
 *      the Clob length +1
 * @throws IOException if accessing underlying I/O resources fail
 */
//@GuardedBy(this)
private long getBytePosition (final long charPos)
        throws IOException {
    long bytePos;
    if (charPos == this.posCache.getCharPos()) {
        // We already know the position.
        bytePos = this.posCache.getBytePos();
    } else {
        long startingBytePosition = 0L; // Default to start at position 0.
        long charsToSkip = charPos -1; // Subtract one to get number to skip
        if (charPos > this.posCache.getCharPos()) {
            // Exploit the last known character position.
            startingBytePosition = this.posCache.getBytePos();
            charsToSkip -= (this.posCache.getCharPos() -1);
        }
        InputStream utf8Bytes =
            this.bytes.getInputStream(startingBytePosition);
        bytePos = startingBytePosition +
            UTF8Util.skipFully(new BufferedInputStream(utf8Bytes),
                               charsToSkip);
        this.posCache.updateCachedPos(charPos, bytePos);
    }
    return bytePos;
}
 
Example 20
Source Project: sofa-jraft   Source File: ProtoBufFile.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Load a protobuf message from file.
 */
public <T extends Message> T load() throws IOException {
    File file = new File(this.path);

    if (!file.exists()) {
        return null;
    }

    final byte[] lenBytes = new byte[4];
    try (final FileInputStream fin = new FileInputStream(file);
            final BufferedInputStream input = new BufferedInputStream(fin)) {
        readBytes(lenBytes, input);
        final int len = Bits.getInt(lenBytes, 0);
        if (len <= 0) {
            throw new IOException("Invalid message fullName.");
        }
        final byte[] nameBytes = new byte[len];
        readBytes(nameBytes, input);
        final String name = new String(nameBytes);
        readBytes(lenBytes, input);
        final int msgLen = Bits.getInt(lenBytes, 0);
        final byte[] msgBytes = new byte[msgLen];
        readBytes(msgBytes, input);
        return ProtobufMsgFactory.newMessageByProtoClassName(name, msgBytes);
    }
}
 
Example 21
Source Project: Telegram   Source File: AudioInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static AudioInfo getAudioInfo(File file) {
     try {
         byte header[] = new byte[12];
         RandomAccessFile randomAccessFile = new RandomAccessFile(file, "r");
         randomAccessFile.readFully(header, 0, 8);
         randomAccessFile.close();
         InputStream input = new BufferedInputStream(new FileInputStream(file));
         if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p') {
             return new M4AInfo(input);
         } else if (file.getAbsolutePath().endsWith("mp3")) {
             return new MP3Info(input, file.length());
         } else {
         	return null;
}
     } catch (Exception e) {
         return null;
     }
 }
 
Example 22
public AudioFileFormat getAudioFileFormat(URL url)
        throws UnsupportedAudioFileException, IOException {
    InputStream stream = url.openStream();
    AudioFileFormat format;
    try {
        format = getAudioFileFormat(new BufferedInputStream(stream));
    } finally {
        stream.close();
    }
    return format;
}
 
Example 23
/**
 * Accept a connection. This method will block until the connection
 * is made and four bytes can be read from the input stream.
 * If the first four bytes are "POST", then an HttpReceiveSocket is
 * returned, which will handle the HTTP protocol wrapping.
 * Otherwise, a WrappedSocket is returned.  The input stream will be
 * reset to the beginning of the transmission.
 * In either case, a BufferedInputStream will already be on top of
 * the underlying socket's input stream.
 * @exception IOException IO error when waiting for the connection.
 */
public Socket accept() throws IOException
{
    Socket socket = super.accept();
    BufferedInputStream in =
        new BufferedInputStream(socket.getInputStream());

    RMIMasterSocketFactory.proxyLog.log(Log.BRIEF,
        "socket accepted (checking for POST)");

    in.mark(4);
    boolean isHttp = (in.read() == 'P') &&
                     (in.read() == 'O') &&
                     (in.read() == 'S') &&
                     (in.read() == 'T');
    in.reset();

    if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.BRIEF)) {
        RMIMasterSocketFactory.proxyLog.log(Log.BRIEF,
            (isHttp ? "POST found, HTTP socket returned" :
                      "POST not found, direct socket returned"));
    }

    if (isHttp)
        return new HttpReceiveSocket(socket, in, null);
    else
        return new WrappedSocket(socket, in, null);
}
 
Example 24
Source Project: synapse   Source File: KinesisCompactionAcceptanceTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private LinkedHashMap<String, JSONArray> fetchAndParseSnapshotFileFromS3(String snapshotFileName) {
    GetObjectRequest request = GetObjectRequest.builder().bucket(INTEGRATION_TEST_BUCKET).key(snapshotFileName).build();

    ResponseInputStream<GetObjectResponse> responseInputStream = s3Client.getObject(request);
    try (
            BufferedInputStream bufferedInputStream = new BufferedInputStream(responseInputStream);
            ZipInputStream zipInputStream = new ZipInputStream(bufferedInputStream)
    ) {
        zipInputStream.getNextEntry();
        return (LinkedHashMap<String, JSONArray>) Configuration.defaultConfiguration().jsonProvider().parse(zipInputStream, Charsets.UTF_8.name());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
Example 25
/**
 * @see org.newdawn.slick.opengl.LoadableImageData#loadImage(java.io.InputStream, boolean, boolean, int[])
 */
public ByteBuffer loadImage(InputStream is, boolean flipped, boolean forceAlpha, int[] transparent) throws IOException {
	CompositeIOException exception = new CompositeIOException();
	ByteBuffer buffer = null;
	
	BufferedInputStream in = new BufferedInputStream(is, is.available());
	in.mark(is.available());
	
	// cycle through our source until one of them works
	for (int i=0;i<sources.size();i++) {
		in.reset();
		try {
			LoadableImageData data = (LoadableImageData) sources.get(i);
			
			buffer = data.loadImage(in, flipped, forceAlpha, transparent);
			picked = data;
			break;
		} catch (Exception e) {
			Log.warn(sources.get(i).getClass()+" failed to read the data", e);
			exception.addException(e);
		}
	}
	
	if (picked == null) {
		throw exception;
	}
	
	return buffer;
}
 
Example 26
@Before
public void setupStreams() {
    final InputStream srcInputStream = new ByteArrayInputStream("a\nb\nc\nd".getBytes());
    this.logIn = (BufferedInputStream)
        IoBuilder.forLogger(getLogger())
            .filter(srcInputStream)
            .setLevel(LEVEL)
            .setBuffered(true)
            .buildInputStream();
}
 
Example 27
Source Project: netbeans   Source File: WLJpa2SwitchSupport.java    License: Apache License 2.0 5 votes vote down vote up
private void copy(File source, File dest) throws IOException {
    InputStream is = new BufferedInputStream(new FileInputStream(source));
    try {
        OutputStream os = new BufferedOutputStream(new FileOutputStream(dest));
        try {
            FileUtil.copy(is, os);
        } finally {
            os.close();
        }
    } finally {
        is.close();
    }
}
 
Example 28
public AudioFileFormat getAudioFileFormat(URL url)
        throws UnsupportedAudioFileException, IOException {
    InputStream stream = url.openStream();
    AudioFileFormat format;
    try {
        format = getAudioFileFormat(new BufferedInputStream(stream));
    } finally {
        stream.close();
    }
    return format;
}
 
Example 29
Source Project: j2objc   Source File: OldLineNumberInputStreamTest.java    License: Apache License 2.0 5 votes vote down vote up
protected void setUp() {
    /*
     * In order for IOException to be thrown in reset(),the inputStream to
     * the constructor cannot be a byteArrayInputstream because the reset()
     * in byteArrayInputStream does not throw IOException. When
     * BufferedInputStream is used, the size of the buffer must be smaller
     * than the readlimit in mark inorder for IOException to be thrown
     */
    BufferedInputStream buftemp = new BufferedInputStream(
            new ByteArrayInputStream(text.getBytes()), 4);
    lnis = new LineNumberInputStream(buftemp);
    lnis2 = new LineNumberInputStream(new ByteArrayInputStream(dosText
            .getBytes()));
}
 
Example 30
Source Project: olat   Source File: TextDocument.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected String readContent(final VFSLeaf leaf) throws IOException {
    final BufferedInputStream bis = new BufferedInputStream(leaf.getInputStream());
    final String content = FileUtils.load(bis, "utf-8");
    bis.close();
    return content;
}