Problem reading file

int[] occurances = new int[26];
String fileName = "whatever.txt";
fHandel = new FileReader(new File(fileName));     
               while(fHandel.read() != -1)
                    ascii = fHandel.read();
                    current = Character.toUpperCase((char)ascii);
                    if((ascii >= 65 && ascii <= 90) || (ascii>=97 && ascii <= 122));
                                System.out.println("character: "+(char)ascii);
                         occurances[(int)current-65]++;
               }when I print the character to the screen, the first character displayed is the second character, all other characters appear to have no relation to what the actual content of the file is, there isn't even as many characters being displayed as the file has.

while(fHandel.read() != -1) // here you read the next character, if there is one, and ignore it
  ascii = fHandel.read(); // here you read the next character, if there is one

Similar Messages

  • Im using xcode 4.6 and im having problems reading files using the fopen function in c

    Im using xcode 4.6 and im having problems reading files using the fopen function in c

    Yes, but that would not cause the "build  failed" message.
    right I missed that part. Looks like two problems then.
    //  main.m
    //  ASCTestFopen
    //  Created by Frank Caggiano on 3/2/13.
    //  Copyright (c) 2013 Frank Caggiano. All rights reserved.
    #import <Foundation/Foundation.h>
    #include <stdio.h> 
    int main(int argc, const char * argv[])
        @autoreleasepool {
            FILE *fp, *fopen();
            // insert code here...
            if((fp = fopen("~/test.txt","r")) == NULL)
                NSLog(@"open failed");
        return 0;
    This will compile ad run in Xcode with a project type of comand line tool

  • Problem reading files

    Hello,
    the following code reads a file into a byte stream:
    URL url = new URL("some filename under the codebase");
    InputStream inStream = url.openStream();
    int inBytes = inStream.available();           
    byte inBuf[] = new byte[inBytes];
    int bytesRead = inStream.read(inBuf, 0, inBytes);
    inStream.close();
    this code used to work, but after changing virtual machine it doesn't. the problem is that only part of the file is being read. I'm sure there is better code for this situation - any ideas?
    thanks,
    Ori

    Problem is the use of "inStream.available();" available() is not giving you the actual size of the file it gives you the number of bytes that you can read without blocking that means the number of bytes that has be downloaded to the client.
    here is a better solution:
    ByteArrayOutputStream()
    URL url = new URL("some filename under the codebase");
    InputStream inStream = url.openStream();
    ByteArrayOutputStream tempBuffer = new ByteArrayOutputStream();
    byte b[] = new byte[1024];
    int count=0;
    while ((count  = inStream.read(b))!=-1){
                tempBuffer.write(b,0,count);
    inStream.close();
    byte inBuf[] = tempBuffer.toByteArray();By the way what are the data in the file that you are reading If it is it text or something else
    If it is text you can directly use DataInputStream to read line by line

  • Problem reading file in tomcat

    Hai I have a problem,
    i am working on project for which we have created a directory in the defaultroot directory of the apache tomcat server.I have written a java program to read a file.Now the problem is coming as to where to put the file and if i want to place that file in the created directory under defaultroot,what path should i give to access this file..
    for eg: i want to put the file test.txt under the folder /defaultroot/test/test.txt then what path should i give in my java program. if i use ../test/test.txt then it says path is not present since using ../ is going into the tomcat directory. i can explicitly give ../defaultroot/test/test.txt but i dont want to hardcode defaultroot. Any suggestions?
    thanks

    U can considering having the path in a property file and using it in the problem

  • Problem reading file after using webutil_file_transfer.as_to_client

    Hi all,
    The Forms webapplication I'm working on has to talk with a cardreading-application on the client-PC. The communication is carried out by exchanging small files. Reading from the client by Forms on the AS goes well (using client_text_io from webutil). The problem arises when the application has to respond back with a file. The file is made on the AS and then transfered from the AS to the client using webutil_file_transfer.as_to_client. This file can not be read by the cardreading application when the AS is on Linux. Our developement AS server is on a Windows 2000 box and then the communication doesn't show this problem.
    If I open the file from the AS on Linux , I can see that there is only 1 long line. The Windows version of the file contains 2 lines (as it should be). It seems that before/during/after the transfer some special characters like carriage return and tab are causing the problem.
    Looking in web_file_transfer.as_to_client I see that the procedure reads lines from a temporary file into a buffer. The lines are separated by a CHR(10). Could the transfer from Linux to Windows(DOS) cause a problem with these characters ?
    Has anyone experienced this problem ? If someone has a clue this would be very welcome.
    We work with :
    - Forms and AS 10.1.2.0.2
    - Webutil 1.0.6
    - Development OS: Windows 2000 (Service Pack 4)
    - Production OS: Red Hat Enterprise Linux AS release 3 (Taroon Update 3)
    - Client-PC OS: Windows 2000 (Service Pack 4)
    Thanx,
    Enrico

    Without going into a long winded answer, the only thing I can really offer is to say this... If you feel as though your code has been correctly written and you simply cannot identify any other possible solution, add SYNCHRONIZE. In short, its execution acts similar to a reset or refresh button.
    Another common place where SYNCHRONIZE has been helpful is when calling RUN_REPORT_OBJECT. For example, if you use the code we offer in the Forms/Reports Integration document you will find that it works very well - most of the time. However, sometimes it fails for what seems to be unexplainable reasons. If you message out the values being assigned you will see that some variable values are not being set even though the code execution has already passed the point where a value should have been assigned. Adding the SYNCHRONIZE just after the point where the value should have been assigned forces the assignment before executing the next line of code. For example,
         v_rep := RUN_REPORT_OBJECT(repid);
         rep_status := report_object_status(v_rep);
    In the above code, a request for a report is made followed by a check of its status. At this point you would expect that the status would be something like one of the following:
         'RUNNING', 'OPENING_REPORT', 'ENQUEUED'
    However, we have seen instances where the value assigned to the variable would actually be NULL, which of course will make the rest of the code likely fail. By adding SYNCHRONIZE the problem is correctable.
         v_rep := RUN_REPORT_OBJECT(repid);
         rep_status := report_object_status(v_rep);
         SYNCHRONIZE;
    It is important to understand, however that using SYNCHRONIZE comes at a price. Each time it is executed a network round-trip occurs which will give the application the appearance of degraded performance. So use this built-in only when you know you must.

  • Problems reading files. Updated

    Hello
    This is a update for my old topic, my real problem was read the file and then pass to a String variable, I try to read the file in binary mode, then the buffer with data pass to a String with the constructor String a = new String( bytearray, 0. bytearray.length()); then the problem occurs, the non printable characters appear like ?, I don't want this behavior
    Can you help me on this?
    Thanks

    How about something like this?BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("my file name"))));
    String s = br.readLine();Mark

  • Cfhttp problem reading file

    Hi there,
    The code below works fine on my local host computer and
    databse setup.
    cfhttp will read my file fine and output the number of rows.
    When i attempt to run this code on my web host's CF and MS
    II's server i get
    a - HTTP 500 - Internal server error in Internet Explorer and
    a blank page
    in firefox.
    Does anybody know why this would be happenning. I've heard
    cfhttp has some
    bugs but i couldnt find a solution after looking at various
    blogs on the
    matter. Not sure if its timing out or what?
    <cfsetting requesttimeout="900">
    <cfhttp method="get" textqualifier=" "
    firstrowasheaders="no" delimiter="|"
    name="test" columns="OrderNo, Line, seq, AccountNo, Shipment,
    Invoice,
    PurchaseOrder, Completed, OrderDate, ShipmentDate, Backorder,
    Product,
    QtyOrdered, QtyShipped, QtyInvoiced, Price, Carrier, Connote,
    Delivery1,
    Delivery2, Delivery3, Delivery4, Delivery5, Delivery6,
    Delivery7, expected"
    url="
    http://xxxxxx.com/xxx/zzzzz.txt">
    Read in <cfoutput>#test.RecordCount#</cfoutput>
    records

    Heres my complete code what im trying to achieve. In IE i get
    a http 500
    internal error and in firefox i get a blank page. im strating
    to think it
    may be a database permission problem although i have made
    sure my user has
    full permissions on the order_history table.
    any ideas whta im doing wrong?
    <cfquery name="delete" datasource="#client.dsn#"
    username="#client.username#" passWord="#client.password#">
    delete from order_history
    </cfquery>
    <cfhttp timeout="900" method="get" textqualifier=" "
    firstrowasheaders="no"
    columns="OrderNo,Line,seq,AccountNo,Shipment,Invoice,PurchaseOrder,Completed,OrderDate,Sh ipmentDate,Backorder,Product,QtyOrdered,QtyShipped,QtyInvoiced,Price,Carrier,Connote,Deliv ery1,Delivery2,Delivery3,Delivery4,Delivery5,Delivery6,Delivery7,expected"
    delimiter="|" name="test" url="
    http://xxxxxxxx.com/prms/ordhist1.txt">
    </cfhttp>
    <cfloop query="test">
    <cfquery name="insert" datasource="#client.dsn#"
    username="#client.username#" passWord="#client.password#">
    INSERT INTO order_history
    (OrderNo, Line, seq, AccountNo, Shipment, Invoice,
    PurchaseOrder, Completed,
    OrderDate, ShipmentDate, Backorder, Product, QtyOrdered,
    QtyShipped,
    QtyInvoiced, Price, Carrier, Connote, Delivery1, Delivery2,
    Delivery3,
    Delivery4, Delivery5, Delivery6, Delivery7, expected)
    VALUES (
    <cfqueryparam value='#test.OrderNo#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.Line#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.seq#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.AccountNo#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.shipment#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.invoice#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.purchaseorder#'
    cfsqltype="cf_sql_varchar"
    maxlength="20">,
    <cfqueryparam value='#test.completed#'
    cfsqltype="cf_sql_varchar"
    maxlength="12">,
    <cfqueryparam value='#test.orderdate#'
    cfsqltype="cf_sql_varchar"
    maxlength="12">,
    <cfqueryparam value='#test.shipmentdate#'
    cfsqltype="cf_sql_varchar"
    maxlength="12">,
    <cfqueryparam value='#test.backorder#'
    cfsqltype="cf_sql_varchar"
    maxlength="10">,
    <cfqueryparam value='#test.product#'
    cfsqltype="cf_sql_varchar"
    maxlength="20">,
    <cfqueryparam value='#test.qtyordered#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.qtyshipped#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.qtyinvoiced#'
    cfsqltype="cf_sql_integer">,
    <cfqueryparam value='#test.price#'
    cfsqltype="cf_sql_varchar"
    maxlength="15">,
    <cfqueryparam value='#test.carrier#'
    cfsqltype="cf_sql_varchar"
    maxlength="20">,
    <cfqueryparam value='#test.connote#'
    cfsqltype="cf_sql_varchar"
    maxlength="20">,
    <cfqueryparam value='#test.delivery1#'
    cfsqltype="cf_sql_varchar"
    maxlength="150">,
    <cfqueryparam value='#test.delivery2#'
    cfsqltype="cf_sql_varchar"
    maxlength="100">,
    <cfqueryparam value='#test.delivery3#'
    cfsqltype="cf_sql_varchar"
    maxlength="100">,
    <cfqueryparam value='#test.delivery4#'
    cfsqltype="cf_sql_varchar"
    maxlength="100">,
    <cfqueryparam value='#test.delivery5#'
    cfsqltype="cf_sql_varchar"
    maxlength="100">,
    <cfqueryparam value='#test.delivery6#'
    cfsqltype="cf_sql_varchar"
    maxlength="100">,
    <cfqueryparam value='#test.delivery7#'
    cfsqltype="cf_sql_varchar"
    maxlength="100">,
    <cfqueryparam value='#test.expected#'
    cfsqltype="cf_sql_varchar"
    maxlength="12">)
    </cfquery>
    </cfloop>
    FINISHED!!
    "jdeline" <[email protected]> wrote in message
    news:[email protected]...
    > You need </CFHTTP> after your <CFHTTP>.

  • Problems reading files

    Hi,
    I'm, trying to read a file that has a format similar to a sorce code.
    This is the content of the file:
         BEGIN
              CLOCK_LOOP : LOOP
              END LOOP CLOCK_LOOP;
         END PROCESS;
    I'm using the following code:
    while((line = br.readLine()) != null) {     
         String result = "";
    String delimiters = "+-*/(),. ";
    StringTokenizer st = new StringTokenizer(line, delimiters, true);
    while (st.hasMoreTokens()) {
    String w = st.nextToken();
    if (w.equals("BEGIN")) {
         System.out.println(line);
    This works perfectly. But I need to read the lines starting from CLOCK, so when I change the word BEGIN to CLOCK i get this error:
    Error de E/S java.net.SocketException: Connection reset
    How can I solve this?

    I did what you told me, so this is what I'm trying now:
    while((line = br.readLine()) != null) {     
    String result = "";
    String delimiters = "+-*/(),. ";
    StringTokenizer st = new StringTokenizer(line, delimiters, true);
    while (st.hasMoreTokens()) {
    String w = st.nextToken();
    if (w.equals("BEGIN")) {
                   System.out.println(line);
                   break;
    while((line = br.readLine()) != null) {     
         String result = "";
    String delimiters = "+-*/(),. ";
    StringTokenizer st = new StringTokenizer(line, delimiters, true);
    while (st.hasMoreTokens()) {
    String w = st.nextToken();
    if (w.equals("LOOP")) {
                   System.out.println(line);
    It only prints BEGIN

  • RE: [Adobe Reader] when i open pdf file it open all the pages but some pages give error massage (there was error processing a page,there was a problem reading this document 110) but if i open this page which give me error with google chrome it's work ? i

    HelloThank's for your helpsI hope this document is helpfulBest Regards,
    Date: Sun, 22 Jun 2014 17:10:17 -0700
    From: [email protected]
    To: [email protected]
    Subject:  when i open pdf file it open all the pages but some pages give error massage (there was error processing a page,there was a problem reading this document 110) but if i open this page which give me error with google chrome it's work ? if you can help me th
        when i open pdf file it open all the pages but some pages give error massage (there was error processing a page,there was a problem reading this document 110) but if i open this page which give me error with google chrome it's work ? if you can help m
        created by Anoop9178 in Adobe Reader - View the full discussion
    Hi,
    Would it be possible for you to share the document?
    Regards,
    Anoop
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6485431#6485431
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
         To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Adobe Reader by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

    thank's for reply and your help
    i did the step's that you told me but  i still have the same problem
                                     i have the latest v.11.0.7
    i
    i disable the protected mode

  • Error while opening pdf in reader in windows 8:Can't open this file. There's a problem with file format

    I have a problem with a pdf file which does not open with reader in windows 8 but it opens properly with adobe pdf reader. All other pdf can be opened in reader.But when i open a pdf(see this link for pdf for which i got error http://incometaxsoft.com/temp/Form.pdf)
    it gives error as "Can't open this file. There's a problem with file format".
    The same file opens properly in adobe pdf reader.You can check the pdf file which i have mentioned in the link above.But the reader which comes with windows 8 can open some other pdf in the same PC.What may be the error causing this??

    This has turned out to be an enormous issue for me as I sell PDF files as ebooks. I have done a fair amount of investigating this for my system.
    My files have to be compatible not just across readers but across operating systems.
    To date, I have over 200 PDFs that have functioned flawlessly across Mac, PC (Windows 7 and below), Android, iPhone/iPad, Linux.
    I personally test my PDFs using a variety of readers and PDF editors including
    PDF XChange (my favorite)
    Foxit (runner up for me and I recommend for most people)
    Adobe (the bloated monster)
    Nitro 9 (great for moving graphical elements around)
    ABBYY
    And the Nuance PDF Create toolsets
    Those are off the top of my head. There are a bunch on Android that I test with too.
    I am running the Windows 10 Pro Tech Preview and I have this same problem so I know it isn't fixed yet in any kind of pre-release way (-sigh-)
    Here is what I've learned for my situation
    The PDFs I created using NUANCE'S PDF CREATE PROFESSIONAL VERSION 8
    all fail using the built-in Windows 8/10 PDF reader.
    When I look at the PDF properties for these Nuance created files, the underlying engine used to write them is called "ImageToPDF". Using ABBYY it indicates their own engine as does everyone else that I've tried. It is easy for you to check to see
    what created your PDF by doing a "Control D" (look at the document properties). Perhaps there's a common engine causing issues.
    If I use the exact same source files to create a PDF using any of my other tools I have no issues. I checked the PDF versions made by the tools and they are all set to 1.5.
    A customer mentioned being able to convert them in a way they worked by saving them without having to do any kind of extraction, but I have not been able to duplicate that. Perhaps he did a "print" which seems like it could work.
    In summary, the workaround everyone is talking about, using an alternate reader, of course works. But not everyone wants to change.
     The culprit I have found is my Nuance PDF Creation tools that are using the ImageToPDF engine.
    I hope it gets FIXED as I really don't want to have to regenerate all of my PDF files.

  • When i open pdf file it open all the pages but some pages give error massage (there was error processing a page,there was a problem reading this document 110) but if i open this page which give me error with google chrome it's work ? if you can help me th

    when i open pdf file it open all the pages but some pages give error massage (there was error processing a page,there was a problem reading this document 110) but if i open this page which give me error with google chrome it's work ?
    if you can help me thank's
    [email address removed by host]

    thank's for reply and your help
    i did the step's that you told me but  i still have the same problem
                                     i have the latest v.11.0.7
    i
    i disable the protected mode

  • Problem with saving a pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21).

    Need advice on a saving file issue. I'm having problem with saving a .pdf file to computer. Continually get an error message " This document could not be saved. There was a problem reading this document (21). This is new as this error message just recently started to pop-up.

    More information about this issue can be found here:
    https://forums.adobe.com/thread/1672655
    A "quick" fix that worked for me was to uninstall Adobe... then download the base install for Adobe Reader 11.0.
    Then download each of the individual updates and run them sequentially. 
    I've installed back up to the last security update which is version 08 and have been able to do normal Save As operations.
    You will have to disable automatic updates in order to stay at version 08 until Adobe resolves this issue in a later release.
    http://www.adobe.com/support/downloads/product.jsp?product=10&platform=Windows
    Adobe Reader 11.0 - Multilingual (MUI) installer    AdbeRdr11000_mui_Std
    Adobe Reader 11.0.01 update - Multilingual (MUI) installer    AdbeRdrUpd11001_MUI.msp
    Adobe Reader 11.0.02 update - All languages    AdbeRdrSecUpd11002.msp
    Adobe Reader 11.0.03 update - Multilingual (MUI) installer    AdbeRdrUpd11003_MUI.msp
    Adobe Reader 11.0.04 update - Multilingual (MUI) installer    AdbeRdrUpd11004_MUI.msp
    Adobe Reader 11.0.05 security update - All languages    AdbeRdrSecUpd11005.msp
    Adobe Reader 11.0.06 update - Multilingual (MUI) installer    AdbeRdrUpd11006_MUI.msp
    Adobe Reader 11.0.07 update - Multilingual (MUI) installer    AdbeRdrUpd11007_MUI.msp
    Adobe Reader 11.0.08 security update - All languages    AdbeRdrSecUpd11008.msp

  • Can't open file - error "There was a problem reading the layer data.."

    I'm on a
    Mac Pro, 10.5.7
    PSCS3
    I have been sent a file (148MB) from a client via FTP that I can not open. The file was created on a PC, using PSCS3.
    I'm usually pretty good at troubling shooting but I have not seen this before.
    Any help, suggestions would welcomed.
    I get the following error messages: (see attached)

    It looks like the atttachement did not work
    Here are the error messages:
    First message:
    "There was a problem reading the layer data. Read the composite date instead?"
    Second Message:
    "Could not complete your request because the file is not compatiable with this version of Photoshop."

  • Problem reading GoPro Hero Black 4 files (1080p 120 fps) on my iMac with Adobe Premiere Elements

    Hello,
    I have a problem reading GoPro Hero Black 4 files (1080p 120 fps) on my iMac with Adobe Premiere Elements : the file is read but the quality is quite bad. When I watch it with other software like VLC or MPC, the quality is perfect but the video is sometimes slowed or there are some jumps in the reading.
    What is the issue with this ?
    thakns for your help !
    Olivier.

    This is easy. I do it all the time. FCPX ingests GoPro footage just fine. Optimize, and you're good to go.
    BTW: A common hiccup occurs when dealing with over-cranked footage. (60fps or 120fps.) Be sure to "conform speed" to actuate the slo-mo. 'Tis also important to designate your project / timeline at 24fps or 30fps to realize the speed difference.
    I've gotten burned in the past. I'll drag my over-cranked GoPro footage to the timeline. As it is the "first" clip layed into the timeline, the project assumes THAT speed as a default. (As per my preferences.) Thus, when I "conform speed," nothing seems to happen. That's because my project is displaying at the higher rate. A 60fps timeline showing footage shot at 60fps looks "normal speed."
    FYI. (And disregard if you know all this.)

  • Problem reading pdf files, they are incomplete, garbled

    I cannot read or download correctly pdf files. They appear garbled, illegible and incomplete both on screen and when trying to print them.

    I have found a somewhat lengthy solution:
    First open the problem pdf file with Foxit.
    Then save it as the same name file in the same place, overwriting the original file.
    Now open the new file with Adobe Reader and the problem has gone.
    The problem of missing letters when copying text has gone too.
    I have no idea why this works.
    I would still like to learn of a better solution.

Maybe you are looking for

  • Exchange Admin Center 2013 SP1 worked for a day and then stopped working, possible OAB problems

    Here is a problem that has me confused. On a fresh Windows Server 2012 R2, I installed Exchange 2013 SP1. It was successful and for the first day everything was working well. I then installed all security updates. The next day, I could no longer log

  • How to fit greenscreen in imovie '09

    Hi! i am using imovie '09. i'm trying to use the greenscreen function and everything works well except for 1 thing. So there is a small greenscreen in the screen that i am filming. but i want to adjust the size of the video that is playing on the gre

  • My site looks great on the laptop, but does not transfer to desktop screen...

    I designed my site to be on long scrolling page that features several full browser width slidehows. It looks great on the laptop, and I used the scroll motion trick to keep it from sliding horizontally, but when I published my trial version and check

  • How to update my apps

    My ipad3 and mini are showing apps that need to be updated but when I try to update in the App Store there is no update tab.

  • Gallery and camera update for Belle FP2.

    I just installed the update which is available today via software update using Nokia Suite. I'm happy that I got back the mark option to send multiple files. There's an extra preference option provided in camera but it is still taking time for the ca