Android Open Source - SysLog Input Stream Wrapper






From Project

Back to project page SysLog.

License

The source code is released under:

GNU General Public License

If you think the Android project SysLog listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tortel.syslog.utils;
/*from  w  ww . ja  v  a  2 s  . c  om*/
import java.io.IOException;
import java.io.InputStream;

/**
 * Input stream that replaces \n with \r\n
 */
public class InputStreamWrapper extends InputStream {
    private InputStream is;

    public InputStreamWrapper(InputStream in) {
        is = in;
    }

    @Override
    public int read() throws IOException {
        return is.read();
    }

    @Override
    public int read(byte[] b) throws IOException {
        return this.read(b, 0, b.length);
    }

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        int n = 0, c;
        do {
            c = this.read();
            if(c != -1) {
                if(c == '\n') {
                    if(len >= 2){
                        b[off + n] = '\r';
                        n++;
                        len--;
                    }
                }
                b[off + n] = (byte) c;
                n++;
                len--;
            }
        } while(c != -1 && len > 0);
        return n;
    }

    @Override
    public int available() throws IOException {
        return is.read();
    }

    @Override
    public boolean equals(Object o) {
        return is.equals(o);
    }

    @Override
    public void close() throws IOException {
        is.close();
    }

    @Override
    public void mark(int readlimit) {
        is.mark(readlimit);
    }

    @Override
    public boolean markSupported() {
        return is.markSupported();
    }

    @Override
    public int hashCode() {
        return is.hashCode();
    }

    @Override
    public String toString() {
        return is.toString();
    }

    @Override
    public synchronized void reset() throws IOException {
        is.reset();
    }

    @Override
    public long skip(long byteCount) throws IOException {
        return is.skip(byteCount);
    }
}




Java Source Code List

com.tortel.syslog.GrepOption.java
com.tortel.syslog.LiveLogActivity.java
com.tortel.syslog.MainActivity.java
com.tortel.syslog.Result.java
com.tortel.syslog.RunCommand.java
com.tortel.syslog.ZipWriter.java
com.tortel.syslog.dialog.AboutDialog.java
com.tortel.syslog.dialog.CustomPathDialog.java
com.tortel.syslog.dialog.ExceptionDialog.java
com.tortel.syslog.dialog.FaqDialog.java
com.tortel.syslog.dialog.LowSpaceDialog.java
com.tortel.syslog.dialog.OhShitDialog.java
com.tortel.syslog.exception.CreateFolderException.java
com.tortel.syslog.exception.LowSpaceException.java
com.tortel.syslog.exception.NoFilesException.java
com.tortel.syslog.exception.RunCommandException.java
com.tortel.syslog.utils.InputStreamWrapper.java
com.tortel.syslog.utils.ScrubberUtils.java
com.tortel.syslog.utils.Utils.java
jackpal.androidterm.emulatorview.BaseTextRenderer.java
jackpal.androidterm.emulatorview.Bitmap4x8FontRenderer.java
jackpal.androidterm.emulatorview.ByteQueue.java
jackpal.androidterm.emulatorview.ColorScheme.java
jackpal.androidterm.emulatorview.EmulatorDebug.java
jackpal.androidterm.emulatorview.EmulatorView.java
jackpal.androidterm.emulatorview.GrowableIntArray.java
jackpal.androidterm.emulatorview.PaintRenderer.java
jackpal.androidterm.emulatorview.Screen.java
jackpal.androidterm.emulatorview.StyleRow.java
jackpal.androidterm.emulatorview.TermKeyListener.java
jackpal.androidterm.emulatorview.TermSession.java
jackpal.androidterm.emulatorview.TerminalEmulator.java
jackpal.androidterm.emulatorview.TextRenderer.java
jackpal.androidterm.emulatorview.TextStyle.java
jackpal.androidterm.emulatorview.TranscriptScreen.java
jackpal.androidterm.emulatorview.UnicodeTranscript.java
jackpal.androidterm.emulatorview.UpdateCallback.java
jackpal.androidterm.emulatorview.compat.AndroidCharacterCompat.java
jackpal.androidterm.emulatorview.compat.AndroidCompat.java
jackpal.androidterm.emulatorview.compat.ClipboardManagerCompatFactory.java
jackpal.androidterm.emulatorview.compat.ClipboardManagerCompatV11.java
jackpal.androidterm.emulatorview.compat.ClipboardManagerCompatV1.java
jackpal.androidterm.emulatorview.compat.ClipboardManagerCompat.java
jackpal.androidterm.emulatorview.compat.KeyCharacterMapCompat.java
jackpal.androidterm.emulatorview.compat.KeycodeConstants.java
jackpal.androidterm.emulatorview.compat.Patterns.java