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

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 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.

  • 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

  • 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>.

  • 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

  • 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

  • How to read and update the value of property file

    Hi,
    I am not able read the values from property file.
    Please tell me how to read and update the values from property file using Properties class
    This is my property file : - Config.properties its located in D:\newfolder
    Values
    SMTP = localhost
    Now i need to change the value of the SMTP
    New value :
    SMTP =10.60.1.9
    Pls Help me
    Thanks
    Merlin Rosina,

    Post a small (<1 page) example program that forum members can copy and run that demonstrates your problem.

  • 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

  • When Firefox last automatically updated, it suggested that Adobe reader needed updating, now, with Adobe Reader 8, I can no longer print from the internet, only to file. Help please.

    When Mozilla Firefox last automatically updated, it suggested that Adobe Reader needed updating. After updating to Adobe Reader 8, I can no longer print from the internet, only to a file. I know the printer and its interface must be OK because Word prints normally.

    Problem solved, it was my oversight, I had not removed the check from the Print to File box in the print set up.

  • Unable to download from AppStore, updates,etc.Messages 'the installer is damaged' to 'there might be a problem with file ownership and permissions.' I am the owner and only user of a new MBP. What could be going on?

    Is anyone having the same type of problems I'm having with Lion. I have a new MacBook Pro, received 7 weeks ago, preinstalled with Leopard 10.6.7. I didn't migrate anything from my old iMac, wanted a clean install from the Apple Store. While there, I asked for the upgrade to Lion 10.7, however their system was down.
    I  installed it myself, wirelessly about a week later, and Apple emailed me a receipt. Now, I've had to call support directly last week when I lost Mail, Address Book, was unable to open Preview or iTunes, among other problems. Seemed fixed after a session that baffled even the store tech.  Now I am unable to download or install the recent Mac updates for Lion, from the App Store, could not install Adobe Reader, etc. Messages range from 'A network error has occured - Check your Internet connection and try again' to 'The Installer is damaged and cannot open the package. There may be a problem with file ownership or permissions.'  All fail and I'll probably have to call Apple again. I am frustrated beyond words.  Logs 'Install's runner tool is not properly configured as a setuid tool', domain errors, 'attempt to write a readonly database, and on and on. I have barely done a thing on this computer except search online for help with these problems. Safari gives me a 'You are not connected to the internet' too often. Diagnostics disagrees. I do see wi-fi problems in the forum. Disk and permissions were fine at the beginning of the earlier problems, checked first by support tech. I'm not sure if support tech even knew. I was just happy they were fixed. Anyone have these download and/or install problems after a 'clean bill of health' so to speak, only a week ago?

    Let's try the following user tip with that one:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • Problems reading RAW format after update 6.03

    I have problems reading RAW format images into Iphoto 9.6 after update 6.03 or maybe earlier updates (have not imported for a few months). The images show up like half, black or partly distorted. I use a Canon 5D mk2 camera. The images looks okey when read into a PC so I don´t think it is the camera or cables. It has been working very good before! I use a Powerbook pro 13 late 2011 with Yosemite 10.10.1.

    Try downgrading back to 6.02 by following the directions in this post by léonie:
    Apple image including Apple logo changes for feature 126 Apple image ends here
    Dec 28, 2014 7:36 AM
    Re: Digital Camera Raw Compatibility 6.02 - Nikon D800
    in response to ceylin.e
    [DocumentBodyStart:3bf5afd7-94e9-4fb4-acfa-7aa13198efec]
    Make a backup of your system and try to downgrade the RAW support to version 6.01
    To downgrade the RAW Support to the last version from before the last update try this:
    To reinstall the 'RAW Compatibility Update' it is necessary to uninstall the currently installed raw support. Otherwise the installer will rightfully say, that you already have the latest version installed.
    If your tests are showing that the problem happens also in a different user account, try this:
    The RAW support files are installed in the System Library in the folder "/System/Library/CoreServices" Folder:
    To open this folder, use the Finder's "Go" menu. Click the smiling Finder icon in the Dock to bring the Finder forward.
    Then type the keyboard shortcut ⇧⌘G  (for "Finder > Go > Go to folder")  and copy and paste "/System/Library/CoreServices" into the text field. Click the "Go" button.
    In the Finder window that will open, delete both the files "RawCamera.bundle" and "RawCameraSupport.bundle". You will have to enter your Administrator password. (don't empty the Trash, so you can put the files back, if need be)
    Download the current RAW support update from Apple's Support Site:
    Digital Camera RAW Compatibility 6.01 http://support.apple.com/kb/DL1777?viewlocale=en_US&locale=en_US
    In the Downloads folder you will find the disk image with the installer. Double click it to open and run and the installer.
    Then restart your Mac.

  • I just stared having problems with importing files from nikon D810 into LR 5.7 it pop a window saying it can not read files on working on a imac 27" running yosemite on my mac pro after a few times it finally was able to read files and import them into LR

    I just stared having problems with importing files from nikon D810 into LR 5.7 it pop a window saying it can not read files on working on a imac 27" running yosemite on my mac pro after a few times it finally was able to read files and import them into LR I never had this problem before was there some kind of update that could of cause this?

  • Problem reading camera raw files after I reinstalled LR4.

    Now can't read Nikon 5200 camera raw (nef) files in Develop Mode. Could do so before. Any suggestions?

    Thank you all!!!! I was successful in updating!!!!! Appreciate your assistance!
    Date: Sun, 3 Nov 2013 06:35:19 -0800
    From: [email protected]
    To: [email protected]
    Subject: Problem reading camera raw files after I reinstalled LR4.
        Re: Problem reading camera raw files after I reinstalled LR4.
        created by JimHess in Photoshop Lightroom - View the full discussion
    The file that you downloaded is a self-contained running application that installs the update on your computer. After you download that file, you need to double-click on it and follow the prompts to install it. After it has completed you will have Lightroom 4.4 installed and it will be ready to run. If you are on a Windows computer, the installation will replace your 4.1 installation. If you are on a Mac then you will have both versions installed and you will have to be sure you start the right one.
         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 http://forums.adobe.com/message/5810683#5810683
         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: http://forums.adobe.com/message/5810683#5810683
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5810683#5810683. In the Actions box on the right, click the Stop Email Notifications link.
               Start a new discussion in Photoshop Lightroom at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

Maybe you are looking for