Parse lines out of a StringBuffer and/or InputStream

I am loading and parsing a ~40MB text file. I am retrieving this file using the JCraft JSch SFTP library. This has given me no problems so far.
Since I need to process this file line by line, my first approach was to read a character at a time off the InputStream provided by the SFTP library, collect characters until a new line was reached, then parse the line. This proved to be extremely slow. Now I'm pulling 1024 characters at a time into a byte[] from the stream and pushing that array into a StringBuffer until the end of the stream has been reached. It has sped up considerably, but now I don't know what the best way would be to process the buffer.
What would be the best way to split off and process every line of this file? It seems redundant to pull the whole thing into a string buffer then parse it again by using charAt() and substring() to find and chop off lines. Reading character by character from the stream works in theory but is much too slow. Trying to parse the byte[] with fragments of lines is impractical and error prone.
Memory is not an issue since it is running on a dedicated batch server, but speed is important.
Thank you.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class ReadLines {
    public static void readLinesFromInputStream(InputStream is)
         throws IOException {
     BufferedReader reader = new BufferedReader(new InputStreamReader(is),
          1024 * 1024);
     String line;
     while ((line = reader.readLine()) != null) {
         System.out.println(line);
}Piet

Similar Messages

  • No audio (line-out) for some QT and all Real Player

    This is strange.
    This link, which uses Quicktime, will only play SOUND via my internal speakers: http://www.umeportal.com/player.aspx?fid=393&ftyp=3&pgid=7&hid=13728&fp=qt
    While this link will play SOUND via external speakers: http://www.apple.com/getamac/
    Same with all the HD trailers: http://www.apple.com/trailers/ The the SOUND plays externally ok.
    Here's another one that will ONLY play from internal speakers: http://www6.islandrecords.com/site/promo/quicktime/killersbonesquicktime.html
    Real player, will play SOME mov files externally, but most others mp3, mpg, mov, will ONLY play via internal speakers.
    Ok, what gives?

    Ugh....nevermind.
    I removed USB Overdrive and external audio started working for everything.
    This is strange becaues I have been using USB overdrive for about a week w/out any issues.
    At the time I noticed the problem...I had been using QT to convert mov files to h.264, mpeg4, Sorensen 3 files and for some reason, using the QT export features -- with USB Overdrive installed -- mucked up audio play back. Go figure.
    Mac Pro 3Ghz/2GB RAM/ATI Radeon X1900 XT   Mac OS X (10.4.3)  

  • Audio through Line Out a bit muffled and boomy

    I am playing music in iTunes through my old Sony amp and Wharfedale speakers connected with all-right-quality speaker cables.
    In iTunes I have to play around with the equaliser to get acceptable sound quality but it will still not be as good as when I play a CD on the CD-player that is connected to the same amp.
    I also tried using the headphones output but the result was the same.
    Any suggestions on how to improve the sound?
    /p

    Make sure "Sound Enhancer" is turned off in iTunes' "Playback" preference.

  • Line Out: broken ground connection?

    Hi!
    At home, I ususally connect my MacBook Pro with my stereo using the line out socket to listen to music.
    Today, after coming home from work, I plugged in my stereo into the line out of my MacBook and all I got was some nasty buzzing. Just like if there was no ground connection between the Mac and my stereo. The internal speakers worked fine.
    So I plugged in my headphones and started an AC/DC song. The guitars where OK, but the drums, the base and Bon Scott was gone. Yes I know, Bon Scott died some 30 years ago, but I mean: His voice could not be heard. The line out combined with the headphones now act like a karaoke machine, cancelling out the vocals.
    Looks like there's no ground connection and the headphones are drawing all the current through the left an right channel, creating an out-of-phase cancellation effect.
    Does anybody experience the same "lost ground connection" with their line out?

    I don't have a mac, but am having a similar issue with my first gen iphone. Weird thing is for me, only headphones are affected (no center), while any speakers (line out) seem to play fine.

  • Line out audio line level too low to be useable, just started after update

    I'm pretty sure this is a software issue. My line out level is so low it is not useable. Headphone jack still works. I removed all the audio preferences, cleared the cache, rebooted, reconfigured audio midi setup. I maxed out the volume, used the sound preference pane and selected line out. No improvent.
    I picked up an m-audio Fast Track for now. Has anyone experienced this and resolevod it. I'm running 10.5.8...
    < Edited by Host >

    I put my son's PPC Mac Mini in target disk mode and booted off of it. Audio issue still persists. I wonder if the digital out / line out switch has a non volitile register ? or it could be fried ? I booted linux on onthe box and used alsamixer
    I saw the ES9168 (or something like that).. that's the switch right ? It had no value.
    I guess for now I'll get an Maudio device for sound.. but I still hope to figure our what if this is a software issue or is it hardware. The signal is low.. I put my oscilloscope on across the speaker inputs while a sound was playing.. 25mv! It's supposed to be 1v. I don't know how they designed the line out, there is no schemetic. I wonder if what happened is the line out pre-amp blew and I am hearing whatever signal is leaking/bridging across.
    Everything else on my late 2005 powermac g5 is fine. It may be 5 years old but I can render HD video fine, and it's been very stable so I figured I'll keep it till it dies. There's one problem with that though. I've got over 3000 pictures in iPhoto that I shot, and my perl/php development projects are on it, plus my family videos are all on it I server them up to the Apple tv. Ahh.. I guess I have to backup / archive to something that will be compatible.
    Well.. I'll start saving.
    If you can think of any other possibilities let me know. I kind of think booting off the imac in target disk mode ruled out software, but then again the audio driver may be different from the one my G5 uses. Is there any Apple Service Disk kicking around for a Powermac G5 late 2005 model ? Maybe there's code on there to test / initialize the onboard audio.

  • Qosmio X770-11C - how to disable on board speakers when using Line Out?

    Hi,
    Is there any way to disable on board speakers when the line out is used.
    Currently if I plug in a cable to the hadphone socket and choose lineout on the realtek control panel, the sound is output to the line out as expected but also through the internal speakers.
    Is there any way to stop this, and only have sound going out through the line out?
    thanks
    Graeme

    If you want to hear sound on headset only you must choose Headphone option.
    Disconnect cable and connect it again. When you see small window on the screen where you can choose between headphone and line out options choose headphone and you will hear sound on external device only.
    In case you have disabled this popup dialog you can activate it manually. Open Realtek manager connect external device and when you see activated black point on the right side make double click there and change settings.

  • Possible to use both optical out AND regular line out at the same time?

    I currently have my computer speakers (logitech z560) hooked up to the mac pro via regular stereo jack in the back. I have an extra receiver that I would love to hook in to supply me with some needed sound for movie watching and what-not.. Is there a way to enable both line out - digital and line out at the same time?

    You can set DVD Player's "Audio output" to "Digital Out" in its "Disc Setup" preference, while other applications use Line Out.
    You could use a splitter on Line Out to feed your current speakers, and analog Line In on your receiver. When you want sound to both systems, set the receiver to Line In. When you want to watch DVDs, set it to Digital In. This will give you surround sound if the DVD has multichannel sound, and the receiver supports more than two channels.
    If you really want the same output on the Mac Pro Line Out, and Digital Out, you can use the "Auxiliary Device Output" effect in Audio Hijack Pro
    <http://www.rogueamoeba.com/audiohijackpro/>
    It will not support more than two-channel audio.

  • 2009 Mac Pro no audio out from Line Out and/or Digital Out.

    Hey guys, I recently bought a new tv which has an optical input and thought I'd buy an optical cable to connect it to my Mac Pro's (4.1 model 2009 I believe) digital out port which I have never used before .
    The issue I'm facing since is that I can't get out from my mac pro to my tv. I also bought a cable to direct sound from my mac pro's line out, to my tv's red/white stero audio ports.That didn't work either.
    When I select Digital out as the default audio output in Sound preferences the OS says that there are not default audio controls for that device and the sound icon in the menu bar is greyed out while when I switch to line out output I can control volume but no audio is coming from my TV.
    I've been searching on forums and didn't find any relevant answer so if someone knows what may cause this that'd be really helpful.
    *ALSO: I've got windows 8 instaleld on my mac pro as well. The digital out doesn't work there as well although the line out does send sound to the TV.
    ** I also have soundflower installed and perian although I don't think any of them would mess things up like that.
    Do you think this is a problem with my Mac or is this a common Mavericks issue (sorry forgot to mention I'm on 10.9.2)
    Many Thanks,
    Thanos.

    When I select Digital out as the default audio output in Sound preferences the OS says that there are not default audio controls for that device and the sound icon in the menu bar is greyed out
    That's normal.  Is the correct audio input selected on the TV?

  • Line out and headphone problems

    Just recently I have started to have a problem where if I use the line-out funtion of my iPod audio will not come out of the headphones afterwards. I use the Belkin auto-kit so I just connect my iPod whenever I drive somewhere, and it annoys me that I have to reset my iPod every time I want to listen through my headphones. I have tried unplugging and plugging back in, increasing and decreasing the volume, pausing/resuming, and changing songs but to no avail. The only solution is resetting the iPod. I was just wondering if anyone out there has had this problem, or knew if there was a more practical solution than just resetting the iPod every time.
    5g iPod 30GB   Windows XP Pro  

    Went to the genius bar earlier today to have my Mac Pro looked at. They said that front board and backplane failure is fairly common. In fact, the genius mentioned that his own 12-core suffered the same issues insofar as audio crackling and eventual analog out failure.
    I should be getting it back in 5-7 days.

  • IBolt dock w/ music and navigation enabled - Line out speaker glitch

    This has happened 4 times since the JB update when in the car dock mode while cradled in the iBolt. 
    connection:
    - cradled in iBolt dock
    - connect line out to vehicle input jack
    - enables car dock mode
    steps:
    - play a music app
    - start navigation app
    - proceed to destination
    trigger:
    - line out connection glitches when voice navigation speaks
    symptoms:
    - sound starts to come out of phone speakers and line out stops
    - sound comes out of both phone speaker and line out simultaneously

    I believe this problem is partially due to an  improper reload I was just notified of. I have reset the timeouts to 70,  and although I am still unsure as to why two of the phones reset to 10  (most likely causing this issue), the issue seems to be solved for the  moment, hovwever I will keep this thread open to any suggestions in case  this solution in fact does not solve the issue. The real test will be  the business day tommorow .
    -Pat

  • CPU whine with DVI and line out/DVI removed whine not in line out?

    I have noticed that when using headphones or the line out alone I do not hear the whine noise. The whine noise is still active, in other words, I can still hear it coming from the keyboard. But, it is not transferred through the line out or headphone jack. THIS IS BEFORE I DO ANY TRICKS: mirror widget etc.
    But, if I plug in the DVI adaptor and utilize the line out/headphone jack, the noise now appears. This means if I am running my laptop to do a presnetation, the noise will appear through the sound system. However, if I don't use my laptop for video and use it for audio only, the noise is not THERE!
    Of course, I can use the tricks and it will eliminate it. But this leads me to believe that something is related? The DVI connection with the entire mother board....or something. Any comments? Please help

    I agree. I never use line in/out of the computer for professional work. I had PCI expansion chassis doing that type of work when using the PowerBook, and am eagerly awaiting Magma's upgrades which will come soon per their emails. However, I do use my portable computer to teach and to present research, at which point lugging a full blown professional system is not an option. In some cases, it would be nice to use the line out while presenting, without having to carry additional equipment.
    In any case, the problem does exist and is one that shouldn't exist. The fact that there are workarounds does not "fix" the problem or for that matter acknowledges it. Apple should acknowledge the problem and replace the faulty parts in the machines affected. I bet that if it was the other way around, say plugging something in the headphone jack would affect the screen resolution, people would be all over the place, and the solution could not possibly be, "just hook an external monitor and it will work fine".
    In the meantime, I am just trying to find out if this is a widespread issue or not to see if it makes sense to return the machine, with which I am absolutely happy otherwise even with the other problems reported.

  • Keyboard line out and griffin imic incompatibility?

    I'm getting horrible background noise when I try to record my keyboard (Yamaha PSR-225GM ) headphone line out through my Griffin iMic into Garageband. I assume it's a level issue but even the keyboard volume control won't fix the problem nor will system settings for the input device. My Sony stereo mic into the same iMic input sounds fine. Headphones attached to the keyboard line out sound fine too so I don't believe it's a quality problem with the line out. Can one not use a headphone output into the Griffin iMic?
    If not, anyone got suggestions for higher quality audio input into the iMic flat panel (e.g. some USB box) that's compatible with various audio equipment (mics, keyboards, guitar amps, 1/4" and 1/8" and RCA plugs etc.)? The iMic has served me fine, but maybe it's time to start looking for something higher quality, and more versatile. Thanks.
    By the way, anyone know why sometimes there's a delay (half second or so) between audio in and the monitors in Garageband, and sometimes not? It makes performance nearly impossible when there's such a big delay.
    SJG
    iMac flatpanel 15   Mac OS X (10.3.9)  
    iMac flatpanel 15   Mac OS X (10.3.9)  
    iMac flatpanel 15   Mac OS X (10.3.9)  
    iMac flatpanel 15   Mac OS X (10.3.9)  
    iMac flatpanel 15   Mac OS X (10.3.9)  

    tell me if I'm on the right track on the
    following theories (I don't know if the following are TRUE):
    I'll do the best I can...
    1) The quater-inch headphone output from the Yamaha
    keyboard is neither "balanced"
    Correct, the headphone-out is not balanced. A balanced output uses 3 wires, a graound, a hot, and another hot that's 180° out of phase with the first. This is a neat trick in that two signals 180° out of phase with each other cancel each other out sp you get zero signal. In the case of a balanced out if noise is introduced, it is in phase on both cables. On the other end when the signal on the out of phase wire has its phase flipped, your original signal is now in phase on both legs, and the noise is 180° out of phase with itself, and thus is canceled out.
    nor impedance matched
    to the Griffin iMic.
    The impedance is not a problem here. As I understand it, the headphone-out is High Impedance, and so is the iMic's In.
    (I'm using a 1/4" to 2.5 mm
    converter cable). I am possibly getting radio
    interference (I DID get a local radio station when I
    touched the plug right!!) and degrading the signal
    because of these two issues.
    Possible. A Low quality cable and or adaptor could offer an entry point for noise.
    2) It may be necessary to put the signal from my
    keyboard's headphone jack into a DI (direct box) to
    get impedance matched to mixer levels - the levels I
    assume the Griffin iMic expects.
    No, this shouldn't be true. A headphone-out is actually much hotter than a Line-In, so the level should be able to offer more than enough signal, and the impedance is matched.
    3) I'm HOPING that a high quality audio-to-USB (or
    firewire) input box can perform the job of the direct
    box.
    It could, but the weak point I see is that you're stuck using a headphone-out instead of a Line-Out. I don't think a DI box is going to help any in comparison.
    Hmmm, I just glanced at your computer list. Doesn't the iMac have a Line-In jack? Have you tried skipping the iMic and going straight into the iMac?
    Finally, if anyone can give me the list of equipment
    in order from a keyboard to Garageband
    I think it could be Keyboard -> Mac
    Other combinations would just be sticking an interface between the two (Keyboard->interface->Mac)

  • Simultaneous audio over HDMI and line out optical

    Anyone know if this is possible on the new mini?
    I currently use an AppleTV with HDMI to TV and optical digital to my older surround processor which does not accept HDMI.
    AppleTV is useful in that it outputs audio simultaneously over all audio connections - I suspect new Mac Mini might only allow single audio output at a time.

    MacProCT wrote:
    Alley_Cat wrote:
    ...I assume by saying this you're implying you can deliver video over HDMI but audio over toslink through the line out i.e. audio out to non-HDMI destinations is not automatically disabled by an active HDMI connection...
    Correct. You choose your audio output in the sound control panel (or Option-click on the sound icon in toolbar).
    That's ideal then really.
    ...- that would then allow HDMI video to TV, toslink to AV processor, and analogue audio from AV processor to TV analogue audio in to use when you only need the audio via TV speakers...
    I doubt the TV will take an analog audio in at the same time as HDMI video in. It likely only accepts analog audio on inputs that are also analog for video (component, s-video, composite).
    You're right, unlilely to be configurable for HDMI, there might be the odd set that allowed something like this but in general most wouldn't.
    ...A small utility/script might be feasible to toggle between the two on the Mini...
    Yes, entirely possible.
    Another option would be to do what I do: Disable the TV speakers and use the receiver for all sound. Since TV speakers suck, this is a great option. I haven't used built-in TV speakers for at least 15 years.
    I generally do that too, just sometimes for late night listening when others are in bed I switch to the TV speakers, but actually it'd be far easier with no TV audio as you'd not run into those instances when both TV and hi-fi are outputting and messing up the audio effect entirely.

  • Line out and Sound Effects revert to Internal Speakers when I reboot. Any suggestions?

    I have an early 2008 Mac Pro that runs fine under Yosemite. The Sound preference panel worked under Mavericks, but now I must open the Sound panel and manually change the output for both Output and Sound Effects from Internal Speakers to Line Out after a reboot. This is irritating and is becoming more so.
    I've zapped the PRAM with no success.
    Would an AppleScript app on startup work? I can't seem to find any appropriate commands in AppleScript that affect these parameters.
    Any help appreciated.

    The script doesn't seem to work on Yosemite. Trolling around in the library, it appears that "audio" is now "sound," which would explain the file not found.
    Or am I missing something?
    Suggestions?

  • Possible to use audio line out and in simultaneously ?

    In the current version of MacBook Pro Retina is it possible to use the analog audio line out and line in both simultaneously ? That is playback as well as record analog audio at the same time.
    Does anyone know what is the audio hardward platform (Codec, DAC, ADC, etc..) in this machine ?
    Thanks!

    Air has a headset jack.
    You can use a splitter
    Mics should be USB capable for best results, almost all headset mics are junk quality.
    then monitoring or listening thru the headphones
    consider using a PRO MIC , such as an Audio Technica AT2020 USB
    http://www.amazon.com/Audio-Technica-AT2020-USB-Condenser-Microphone/dp/B001AS6O YC/ref=sr_1_1?ie=UTF8&qid=1390776580&sr=8-1&keywords=at2020+usb
    or better still use one of these with pro XLR mics:
    http://www.amazon.com/Focusrite-2i2-USB-Recording-Interface/dp/B005OZE9SA/ref=sr _1_1?ie=UTF8&qid=1390776526&sr=8-1&keywords=2i2

Maybe you are looking for

  • Animated Gif - Problem with Frame Delay

    Mac OS X 10.5.8  PSE 6.0 I just created an animated gif by following the steps in PSE Help.  It says that I should be able to adjust the rate at which the images rotate by changing the Frame Delay measurement but I am unable to change it.  In fact I

  • Music will no longer syncs to phone

    I have a BB Pearl 9100, my OS is Windows Vista Home, internet provider is Bell.  I first noticed something was wrong when I receive a phone call yesterday and the ringtone was defaulted to a phone ringtone.  The ringtone was originally a song I synch

  • IMac coming up with a folder and ? on login

    My wife's iMac just crashed. Finder and Safari were both not responding right before it happened. I forced Finder to quit, but Safari wouldn't stop, so I shut the power off. It has been acting up with the little whirrly thing showing up just about an

  • Is it possible to add some offset on the Y-Scale of a graph when autoscale mode is enabled.

    Hi All, I am plotting  on a waveform graph with autoscale mode enabled. I want to have some offset on the upper and lower side of the Y-Scale. Is there any way of implementing this. Thanks in advance, Cooldude  Solved! Go to Solution.

  • XQuery in BPEL PM 10.1.2

    Hi! I'm trying to run a simple XQuery script to manipulate some XML data from my BPEL process... However when i deploy the code I get the following error: [bpelc] [Error ORABPEL-10071]: unresolved xpath function [bpelc] [Description]: in line 74 of "