File Read - Logical Error (I Guess!)

Hello All;
I am stuck to the logic here;
I have my code;
public String kZero(File File) throws Exception
RandomAccessFile fileHandler = null;
try
fileHandler = new RandomAccessFile(File, "r");
long fileLength = File.length() - 1;
StringBuilder sb = new StringBuilder();
for (long filePointer = fileLength; filePointer != -1; filePointer--)
fileHandler.seek(filePointer);
int readByte = fileHandler.readByte() ;
if (readByte == 0xA)
if (filePointer == fileLength)
continue;
else
if (!StringUtils.isEmpty(sb.toString().trim()))
break;
else if (readByte == 0xD)
if (filePointer == fileLength - 1)
continue;
else
if (!StringUtils.isEmpty(sb.toString().trim()))
break;
sb.append((char) readByte);
String lastLine = sb.reverse().toString();
return lastLine;
catch (java.io.FileNotFoundException e)
throw e;
catch (java.io.IOException e)
throw e;
finally
fileHandler.close();
and i use it as a function...
my problem is yes i can get the last line of the text file bu unfortunately i can not get the upper one.
Does anyone have an idea? How to read not the last one but one upper line from the last line?
Ömer KAYA
METU-GGIT

>
Does anyone have an idea? How to read not the last one but one upper line from the last line?
>
Well you break out of the loop and return after you find one line
if (!StringUtils.isEmpty(sb.toString().trim()))
          break;So try not doing that. Count the lines and quit when you have read the number of lines you want.

Similar Messages

  • Kernel: Sandbox: fmfd deny file-read-metadata errors

    Hello there,
    I am befuddled by this one and have checked many forums for a solution but have yet to find one. Since upgrading to MacOS 10.10 on my Mac Mini Mid 2012, I am receiving quite a few messages on my console related to fmfd. It doesn't matter how many times I clean install. As soon as I turn on iCloud bam. They just roll in.
    11/4/14 8:48:39.000 PM kernel[0]: Sandbox: fmfd(331) deny file-read-metadata /Volumes/xxxxxxxx
    11/4/14 8:48:39.000 PM kernel[0]: Sandbox: fmfd(331) deny file-read-metadata /Volumes/xxxxxxxx
    11/4/14 8:48:39.000 PM kernel[0]: Sandbox: fmfd(331) deny file-read-metadata /Volumes/xxxxxxxx
    11/4/14 8:48:39.000 PM kernel[0]: Sandbox: fmfd(331) deny file-read-metadata /Volumes/xxxxxxxx
    11/4/14 8:48:39.000 PM kernel[0]: Sandbox: fmfd(331) deny file-read-metadata /Volumes/xxxxxxxx
    11/4/14 8:48:39.000 PM kernel[0]: Sandbox: fmfd(331) deny file-read-metadata /Volumes/xxxxxxxx
    Sample report:
    fmfd(331) deny file-read-metadata /Volumes/xxxxxx
    Process:         fmfd [331]
    Path:            /usr/libexec/fmfd
    Load Address:    0x101f98000
    Identifier:      fmfd
    Version:         ??? (???)
    Code Type:       x86_64 (Native)
    Parent Process:  launchd [1]
    Date/Time:       2014-11-04 20:51:11.507 -0600
    OS Version:      Mac OS X 10.10 (14A389)
    Report Version:  8
    Anyone have any insight on how to resolve this or even filter them out? I tried filtering them but no dice.
    j

    Hello there,
    Thank you for posting this. After applying 10.10.1 the messages came back and I am not doing the defaults write again. My home directory is on a spare drive as well. I had no choice due to the size of my iTunes library and simply wanting to keep the home directory location consistent. As it turns out, the same thing happens to another similar directory that i've created. This one is a mobile directory and not just a moved user home directory.  I thought maybe resetting ACLs would do the trick but it does not.
    Also - I do not have nor have I ever had Find my Mac turned on for this machine. The one machine it is turned on is my laptop (3rd machine for work) and that one is not showing errors. I built all three of these in identical fashion with clean installs etc. The only difference is the laptop has a solo drive and that's it. Something is breaking. I wish I could follow where its breaking. I hate the messages.
    My other option is to make it so that all applications can use this token/user in my keychain. Is this dangerous?

  • UPDATE : Toshiba Recovery Wizard 'cannot read from source file or disk' error (satellite L500)

    UPDATE 2: Phoned Toshiba tech support again, guided by techie to begin the recovery again. Just before phoning I was able to go into recovery options and view the drive setup and all the files that couldn't be read are on the CD so I've no idea why the error kept occuring, and neither did the techie. Fingers crossed it works this time but I'm not overly hopefully given that we've just done exactly the same as I did before.  UPDATE 1: I got into the BIOS and reset everything back to defaults and yay, my toshiba recovery wizard now starts! :-D  On the down side, when trying to do a factory default software / out of the box recovery I continually get error messages with regards to copying the files, for example 
    cannot read from source file or disk
    7z.dll
    Type application extension
    size 585kb
    date modified 7/14/2009 10.26pm
    other read / copy errors include PREINST6.SWM, BOOT_32, BOOTPRIORITY, CHECKMAXPTSIZE, CHGBOOT, CPU, CPUCHECK, CREATEPARTITION, CTRLDRVINFO, DISKWIPE, DMI, DPINST32, EBLIB.DLL, ERRORDIALOG, EW3BOOTSEQ, FWLINK, FWLINK.SYS, GETHDDINFO, GETKEYSTATE, IMAGEX, INFILED, INITRECAREA, KRAIADAPI.DLL ..... at which point I decided to 'skip all' :-/
    Any explanations as to what's going on and how I might be able to fix it would be very much appreciated! :-)  Thank you!
    I have a two and half year old satellite L500 with an Intel i-3 and 4 gigs of RAM, on which I was running Windows 7.
    Admittedly it’s had rather a hard life (I ran some very demanding CAD / graphics software on it) but it had always performed well until just recently, when after suffering several BSOD (which had never happened before), the hard drive failed.
    I partitioned and formatted a brand new hard drive (which is perfectly fine and functions normally when hooked up to another laptop with a SATA to USB cable) and obtained system recovery discs from Toshiba.  Unfortunately, when I try and run the first disc, windows starts to load files but then generates an error screen with the message Error F3-F100-0003 and a request to turn the computer off.  
    When I use the windows Memory Diagnostic to get into the Windows Boot Manager Screen I get the following;
    Windows failed to start.  A recent hardware / software change might be the case.
    To fix the problem
    Insert your windows installation disc and restart your computer
    Choose your language settings and click ‘next’
    Click ‘repair your computer’
    File: \boot\memtest.exe
    Status: 0xc000000f
    Info: the selected entry could not be loaded because the application is missing or corrupt.
    I can also use F8 on startup to get into the advanced boot options but selecting any of them simply results in the F3-F100-0003 error message.  I’ve run a memory test using the UBCD, which tells me the memory is fine, and tried another hard drive (which also works perfectly well in another laptop) but no joy.  On phoning Toshiba support the techie said my hard drive had failed, but as I say, both hard drives are perfectly fine / usable when hooked up to another laptop.  I’m now completely stuck as to what the problem is and how I might resolve it – any advice / suggestions would be most gratefully received! Thank you in advance :-)

    Satellite L655-S5096
    Downloads here.
    the second disc gives me the the "cannot read from source file or disk PREINST8.SWM"
    My best guess is that the disc is not readable. Try copying it to another. Sometimes that works.
    Otherwise, order new discs from Toshiba.
    -Jerry

  • Xml files from logic to fcp. translation error

    using final cut pro 5.1.4 and logic 7.3.2. creating a slide version of a musical show i wrote. sent the fcp file to logic as xlm, in order to record the singing along with the prerecorded music aif file. did the vocal record in logic, but when i try to send the xlm back to fcp i get a message: translation error, critical error. so now i have no way to get the file back to fcp, after all that work in logic 7.3.2. alas!! previously i got that same error message and discovered that in logic i had been working in 48,000 sample rate files, but this time around i was careful to avoid that problem, and checked the audio window to be sure everything is in 44,000 files. alas! alas! moan, sigh . . .

    Welcome to the bizarre world of XML.
    Given that you're on Logic 7 then I'm sorry to say that these formats have never been particularly reliable (same with L8), but I heard it's better in L9 but I've not tried it yet.
    Some report no problems, others can't get it to work at all. I can't offer a workaround as I'm not sure what you want to achieve exactly, but I can tell you it's one of those things that's totally unreliable.

  • File system error: The record ID is incorrect. Physical file: . Logical file:

    Hi,
    I face this error message when I try to 'process update' a dimention, sometime it works but sometime it failed with the error below:
    Description: File system error: The record ID is incorrect. Physical file: . Logical file: . 
    My environment: Window Server 2008 R2+SQL Server 2008 R2.
    Note: this issue can be resolved by full cube process, but I can't to that every time if it failed, just want to know what happen at backend of SSAS, It block me neary 2 week without any finding, really appreciate that someone can help on this.
    I have do some research with google, I think the root cause here is not TopCount function(It may be a problem with SQL Server2005), also not the size limitation of 4GB size of .astore file.(I check the size of my cube under 'Data\XXX.db\' folder, which only
    have few MB size).
    Thanks,
    Tom

    Hi Tom,
    Here is a microsoft fix
    FIX: "File system error" occurs when you try to run a process update operation on a dimension in Microsoft SQL Server 2008 Analysis Services and in Microsoft SQL Server 2008 R2 Analysis Services
    In your acenario, in order to fix this issue, please apply the latest Cumulative update and Service Pack according to your SQL Server version. Besides, there are two workarounds in that fix, plese try it and check if it works or not.
    http://support.microsoft.com/default.aspx?scid=kb;en-US;2276495
    Regards,
    Charlie Liao
    TechNet Community Support

  • When i try to install iPlanet App Server on NT, I do not get screen to enter license key valid for evaluation. --- " cache File Read error"

    When i try to install iPlanet App Server on NT, I do not get screen to enter license key valid for evaluation.
    Also during installation screens an error window is displayed saying "cache File Read error -- Could not read ProductKey entry from the cache file "

    Hi,
    I also get the following message:
    "Could not read ProductKey entry from the cache file"
    I have no idea how to provide the installation software with the key. I also tried "keycheck.exe"
    Do you have a solution for this problem? Did you finish the installation?
    Christian

  • Reading .txt file into char array, file not found error. (Basic IO)

    Iv been having some trouble with reading characters from a text file into a char array. I havnt been learning io for very long but i think im getting the hang of it. Reading and writing raw bytes
    and things like that. But i wanted to try using java.io.FileReader to read characters for a change and im having problems with file not found errors. here is the code.
    try
    File theFile = new File("Mr.DocumentReadMe.txt");
    String path = theFile.getCanonicalPath();
    FileReader readMe = new FileReader(path);
    char buffer[] = new char[(int)theFile.length()];
    int readData = 0;
    while(readData != -1)
    readData = readMe.read(buffer);
    jEditorPane1.setText(String.valueOf(buffer));
    catch(Exception e)
    JOptionPane.showMessageDialog(null, e,
    "Error!", JOptionPane.ERROR_MESSAGE);
    The error is: java.io.FileNotFoundException: C:\Users\Kaylan\Documents\NetBeansProjects\Mr.Document\dist\Mr.DocumentReadMe.txt (The system cannot find the file specified)
    The text file is saved in the projects dist folder. I have tried saving it elsewhere and get the same error with a different pathname.
    I can use JFileChooser to get a file and read it into a char array with no problem, why doesnt it work when i specify the path manually in the code?

    Well the file clearly isn't there. Maybe it has a .txt.txt extensionthat Windows is kindly hiding from you - check its Properties.
    But:
    String path = theFile.getCanonicalPath();
    FileReader readMe = new FileReader(path);You don't need all that. Just:
    FileReader readMe = new FileReader(theFile);And:
    char buffer[] = new char[(int)theFile.length()];You don't need a buffer the size of the file, this is bad practice. Use 8192 or whatever.
    while(readData != -1)
    readData = readMe.read(buffer);
    }That doesn't make sense. Read the data into the buffer and repeat until you get EOF? and do nothing with the contents of the buffer? The canonical read loop in Java goes like this:
    while ((count = in.read(buffer)) > 0)
      out.write(buffer, 0, count); // or do something else with buffer[0..count-1].
    jEditorPane1.setText(String.valueOf(buffer));Bzzt. That won't give you the content of 'buffer'. Use new String(buffer, 0, count) at least.

  • Illustrator files cannot be opened: Could not read the file because an error has occurred.

    I cannot open some files from  Illustrator which contain PNG files placed. When I try to open the file, I get a message saying: "this png contains addtional data for Adobe fireworks, which will be discarded upon save." When I press "ok" I get the same screen again. When I press "cancel" I get: "coulld not read the file because an error has occured". I am currently working on a Mac Mavericks. Using Illustrator cc and Fireworks CS6.

    Eliana,
    If you have some file corruption, one thing often tried first is to create a new document and File>Place the (PDF contents, if any of the) corrupted one to see how much may be rescued that way.
    Here are some websites where you can see whether it can rescue the actual file, and if it can, you may pay for a subscription to have it done,
    http://www.recoverytoolbox.com/buy_illustrator.html
    http://markzware.com/adobe-software/fix-illustrator-file-unknown-error-occurred-pdf2dtp-fi le-recovery/
    http://www.illustrator.fixtoolbox.com/
    As far as I remember, the first one is for Win and the second one is for Mac, while the third one should be for both.
    Here are a few pages about struggling with it yourself:
    http://daxxter.wordpress.com/2009/04/16/how-to-recover-a-corrupted-illustrator-ai-file/
    http://helpx.adobe.com/illustrator/kb/troubleshoot-damaged-illustrator-files.html
    http://kb2.adobe.com/cps/500/cpsid_50032.html
    http://kb2.adobe.com/cps/500/cpsid_50031.html
    http://helpx.adobe.com/illustrator/kb/enable-content-recovery-mode-illustrator.html

  • UTL_FILE - file read error

    Hi,
    I am using UTL_FILE to read one file and write it into other file.
    When i am executing procedure that uses UTL_FILE, i get error "ORA-29284: file read error".
    I have checked that file exists with all permissions (r,w,e). Is there any limitaion of size to be read by utl_file. my file size is 62 kb.
    I have set max_linesize to 32767/
    Can anybody tell me the reason why it is happening?

    can you post the script being used...
    What's the database version
    A database object called Directory is also needed in database that is created using the create directory command which directs to the folder in the file system. Is that already created?
    Regards

  • Adobe Reader 9 is not opening same files in Browser "Error in this Page"

    Adobe Reader 9 is not opening same files in Browser "Error in this Page"
    If I try to open this pdf file manually then its works.
    The Error comes if I try to open Big Files or some else Files in the Browser.
    This Error was not comming with Adobe 8.

    To uninstall Adobe Reader, make sure (using Task Manager's Processes tab) that Adobe Reader is not running.  Browser windows should also be closed.
    If you still cannot proceed, try in Safe Mode, or use the Windows Installer CleanUp Utility.
    P.S. Adobe AIR and Acrobat.com are not directly related to Adobe Reader, and can be uninstalled independently.

  • Hi, I am getting an 'Error 4810 occurred at Sound File Read Open.vi' for the attached wav file (plus many other wav files). Any ideas?

    Hi,
    I am getting an 'Error 4810 occurred at Sound File Read Open.vi' for the attached wav file (plus many other wav files).
    Any ideas?

    No attachment exists.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • ORA-29284: File read error

    Good morning,
    Need to do two flat file on a 2000 lien.
    1 - Read a file. csv
    2 - Keep it plain, unformatted information from a table
    These are the steps I performed to achieve the first goal ...
    1 - READING TEST FILE
    CREATE OR REPLACE DIRECTORY PUBLIC_ACCESS AS 'C:\REPORTES_REY';
    GRANT READ, WRITE ON DIRECTORY PUBLIC_ACCESS TO PUBLIC;
    -- THIS PL / SQL works ok..
    DECLARE
    v1 utl_file.file_type;
    v2 varchar2(600);
    begin
    v1:= utl_file.fopen('PUBLIC_ACCESS','prueba20110218.csv','R'); -- WORKS WELL ...
    --v1:= utl_file.fopen('PUBLIC_ACCESS','sui_facturacion_alcantarillado_15085_2011_01_76845_001.csv','R');
    loop
         begin
              utl_file.get_line(v1,v2);
              dbms_output.put_line('el contenido del archivo es: '||v2);
              exception
              when no_data_found then
              exit;
         end;
              dbms_output.put_line(' - ');  JUMP LINE
    end loop;
         utl_file.fclose(v1);
    exception
         when others then
         dbms_output.put_line(sqlerrm);
    end;
    but when you change the file name by map prueba20110218.csv de-> sui_facturacion_alcantarillado_15085_2011_01_76845_001.csv displays the following error
    ORA-29284: File read error+
    - this error to be?
    I am grateful for the attention and cooperation extended ...
    good day ...
    REYNEL SALAZAR MARTÍNEZ
    Cali-Colombia

    Thank you very much for your cooperation extended
    The file if it exists, the operating system is Windows, I'm running for the line of command and the file is in the same direction as the file prueba20110218.csv
    Segi therefore his advice and remove:
    exception
    when others then
    dbms_output.put_line(sqlerrm);
    then run the following code:
    DECLARE
    v1 utl_file.file_type;
    v2 varchar2(800);
    begin
    v1:= utl_file.fopen('PUBLIC_ACCESS','prueba20110218.csv','R'); FUNCIONA BIEN...+
    v1:= utl_file.fopen('PUBLIC_ACCESS','sui_facturacion_alcantarillado_15085_2011_01_76845_001.csv','R',32767);
    loop
    begin
    utl_file.get_line(v1,v2);
    dbms_output.put_line('el contenido del archivo es: '||v2);
    exception
    when no_data_found then
    exit;
    end;
    dbms_output.put_line(' - ');  SALTO DE LINEA+
    end loop;
    utl_file.fclose(v1);
    exception
    when others then
    dbms_output.put_line(sqlerrm);
    end;
    +/+
    ORA-06502: PL / SQL: error: character string buffer too small numeric or value
    I do not understand the error -> ORA-06502
    thanks...
    good day
    Reynel Salazar Martínez
    Cali-Colombia

  • Source file read error for sqldeveloper

    While downloading SQLDeveloper, after almost 70%complete, i got an source file read error.
    i've tried again to download but the page hangs on the license agreement page after clicking I ACCEPT.
    Please resolve this issue.
    Thanks in Advance
    Using:
    MS Win XP Home
    Firefox 1.5.3
    Tony Garabedian

    sybrand_b wrote:
    Why are you assuming utl_file works with binary files? It doesn't!It does in 10g, where file open mode B was introduced. But even with R mode you should be able to open DOC file. You might (or might not) have problem reading it:
    SQL> declare
      2      fh UTL_FILE.FILE_TYPE;
      3      input_buffer varchar2(4000);
      4  begin
      5      fh := UTL_FILE.FOPEN('TEMP','Stats.doc','r');
      6      UTL_FILE.GET_LINE(fh,input_buffer,4000);
      7      DBMS_OUTPUT.PUT_LINE(input_buffer);
      8      UTL_FILE.FCLOSE(fh);
      9    exception
    10      when others then UTL_FILE.FCLOSE(fh);
    11  end;
    12  /
    ÐÏࡱᠠ              >  þÿ                 2          4      þÿÿÿ    1
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿì¥Á €    ð¿             ¸
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Adobe Lens Profile Creator - ERROR (Detect corners failed because file reading errors ocurred)

    1) I have successfully created a lens profile for a Nikon AF Micro Nikkor 40mm 2.8 lens used in a Nikon D5200 Camera. For this I converted the raw .nef files to .DNG first using Adobe's DNG Converter.
    2) When trying to create another lens profile using the EXACT SAME .DNG files as posted in 1), I am no longer able to create a lens profile because of the message "Detect corners failed because file reading errors ocurred". I am also unable to create any other lens profile using different photos.
    3) I have also tried using a fresh install of Adobe Lens Profile Creator in another mac and I get the exact same error.
    4) I AM ABLE to create a lens profile if I use .jpg files (generated from the same raw .nef files as mentioned) but this doesn't help because then the profiles don't show up when trying to open a raw file in Adobe Camera Raw.
    Please help as this is exasperating.
    Thank you.

    Thanks! I had the same error message in Adobe Lens Profile Creator 1.0.4 for OSX and I found the problem to be the letter ö in the folder name for the DNGs. The lens is an old ISCO-Göttingen and the progress stopped at 2% with the mentioned error message. Changed the folder name and now it works!

  • .mov file gives an error on Logic. Help

    I'm trying to import a .mov file into Logic 9 but it keeps giving me this error - "Main Document - FIN-00000194" cannot be found. Any idea what this means? THe movie plays fine on Quicktime. Its a 7.5 Gb file. Cheers

    Hi Kishore,
    Which OS are you using?
    There are some solutions mentioned on this thread that might be helpful to you :Re: adobe digital editions has stopped working
    You might also want to check the KB : Installing Adobe Digital Editions 2.0 in Windows Vista
    Regards,
    Rave

Maybe you are looking for

  • Import of Addresses not working

    I am trying to import the addresses that I had "backed up" to an external hard drive. But it isn't working. First, I had to replace my hard drive. So, I followed the instructions in the Addressbook Help menu for "Backing up mailboxes and addresses".

  • Smartform print problem in vf03

    Hi friends,              This issue is very critical so kindly help me at ur earliest. 1>There are four invoices attached to my smartform. When i print preview my first invoice no. the o/p comes proper. But ,when i test next subsequent invoice and cl

  • Concurrent program request using db link

    Hi All, We can submit the request to a concurrent program using fnd_request.submit_request(). Can we submit a request using db link i.e. without loging into the Oracle Apps instance? What are the steps to do this? If I am submitting more than one req

  • Polar to rectangular conversion

    I want to enter this foumula =B2*cos(C2) Where B2=4, C2=-30 the result I get from this formula is .617... The answer I'm looking for is 3.46, I know the difference has to do with radians and degrees, but I can't seem to get the answer I want using th

  • Sound out of sync on video on n97

    I HAVE JUST NOTICED THAT THE VIDEOS THAT I HAVE DOWNLOADED ONTO MY N97 HAVE THE SOUND OUT OF SYNC,ANY IDEA WHY AND HOW TO FIX IT?