Problem accessing a file from URL connection

My swing application uses a file(5MB).
I tried to open an inputStrem to this file using following codes:
URL u = new URL("http://..../myfile.jat");
URLConnection uconn = u.openConnection();
InputStream iin = uconn.getInputStream();
DataInputStream in = new DataInputStream(iin);
System.out.println(iin.available());
But it gives me available number of bytes sometimes 6761 and sometimes
1711. But I need the available # of bytes to be equal to 5B.
can anybody tell me how I can do that?
thanks

I think this got posted in the wrong forum, but at any rate: the "available()" method tells you how much data is available to be read at this instant. As soon as you read that data, more data will become available. Write a loop that reads repeatedly until there is no more data available.

Similar Messages

  • Accessing CSV File from URL

    Hi Experts,
    I developing an interface where it need access an CSV file from an URL.
    The url is: http://200.218.208.119/download/fechamento/20100413.csv
    The file is modified every day, then yesterday this file will be: 20100414.csv
    My interface generate the following erros
      <Trace level="1" type="T">---- Plain HTTP Adapter Outbound----</Trace>
      <Trace level="1" type="T">---------------------------------------------</Trace>
    - <Trace level="1" type="B" name="CL_HTTP_PLAIN_OUTBOUND-ENTER_PLSRV">
      <Trace level="3" type="T">Quality of Service BE</Trace>
      <Trace level="1" type="T">Get XML-Dokument from the Message-Objekt</Trace>
      <Trace level="3" type="T">URL http://200.218.208.119:80/download/fechamento/20100413.csv</Trace>
      <Trace level="3" type="T">Proxy Host:</Trace>
      <Trace level="3" type="T">Proxy Service:</Trace>
      <Trace level="3" type="T">~request_method POST</Trace>
      <Trace level="3" type="T">~server_protocol HTTP/1.0</Trace>
      <Trace level="3" type="T">accept: */*</Trace>
      <Trace level="3" type="T">msgguid: A7031081480011DFA526001517D1434C</Trace>
      <Trace level="3" type="T">service: D0B_100</Trace>
      <Trace level="3" type="T">interface namespace: http://bcb.gov.br/xi/OB02</Trace>
      <Trace level="3" type="T">interface name: MI_RFC_OUT</Trace>
      <Trace level="3" type="T">Header-Fields</Trace>
      <Trace level="3" type="T">Prolog conversion Codepage: UTF-8</Trace>
      <Trace level="3" type="T">Epilog conversion Codepage: UTF-8</Trace>
      <Trace level="3" type="T">content-length 133</Trace>
      <Trace level="3" type="T">content-type: text/csv; charset=UTF-8</Trace>
      <Trace level="2" type="T">HTTP-Response :</Trace>
      <Trace level="1" type="T">Method Not Allowed</Trace>
      <Trace level="2" type="T">Code : 405</Trace>
      <Trace level="2" type="T">Reason: Method Not Allowed</Trace>
      <Trace level="2" type="T">HTTP-response content-length 6261</Trace>
    can I help?

    > I developing an interface where it need access an CSV file from an URL.
    This is not supported in PI standard.
    I think the option will be available in PI 7.3, but I cannot promise it.

  • The circuit of my macbook is dead yet the hard drive is fine.  I need to access a file from the hard drive, how can i do this? is there a cable i can connect to another mac that will let me transfer the file?

    The circuit of my macbook is dead yet the hard drive is fine.  I need to access a file from the hard drive, how can i do this? The mac turns on the screen freezes as bright blue.  Is there a cable i can connect to another mac that will let me transfer the file?

    There is another option if the Macbook will start up in Target Disk Mode.
    Restart the computer while holding down the T key. If you see the firewire symbol moving around on the screen you can connect this one to another one in TDM. You will need a suitable cable to connect the two Macs.
    http://support.apple.com/kb/ht1661
    Firewire symbol:

  • Failed to read wsdl file from url

    Hi all,
    I am struggling with WL 9.2, consuming a WSRP enabled portlet at the following point:
    Having created a proxy portlet, refering to the WSDL of the WSRP producer, I did successfully deploy the portal. When accessing the portal and consuming the portlet the following exception is thrown:
    com.bea.wsrp.faults.TransportException: Failed to read wsdl file from url due to -- java.net.ConnectException: Tried all: '8' addresses, but could not connect over HTTP to server: 'www.w3.org', port: '80';
    The WSDL includes a schema (http://www.w3.org/2001/XMLSchema). The URL is definetely accessible by the server.
    I am open for any kind of support ;) Thanks in advance!
    Kind regards,
    Matthias

    Yes, they are all local schemas. The way ALSB works, even if the import path in the wsdl or parent schema doesn't exist, relative to the current directory, you can specify which schema resolves that reference. My WSDL imports several schemas, all of which import others. When I was done importing all the schemas and resolving references, all the references in WSDLs and XSDs were assigned and valid. However, after all of those imports and reference resolution, it still says the WSDL is invalid, with the following odd error message:
    The WSDL is not semantically valid: Failed to read wsdl file from url due to -- java.net.MalformedURLException: no protocol: /XMLSchema/PaymentServices/Resources/PaymentServices-200802.
    That path listed refers to one of the schemas imported by the WSDL. The reference to that schema in the WSDL was resolved, and it doesn't complain about that reference.

  • Access XML files from HTTP

    Hi,
    I need access XML file from HTTP. Server need parameters in the URL to generate XML files. For example, http://fileserver/xmlfile?orderid=123&custid=321.
    I created a XML Data Server in ODI 11g. The JDBC Url should be jdbc:snps:xml?f=<filename>&s=<schema>&d=<DTD>.
    However, it reports error when replaced the <filename> with "http://fileserver/xmlfile?orderid=123&custid=321".
    I found it's caused by ampersand of the HTTP Url. I guess ODI treat custid=321 as JDBC parameter rather than HTTP parameter.
    How to fill the JDBC Url in this situation?
    Thanks,

    i solved my problem by using the Socket object and controlling my file access by writing requests to the outputstream

  • Problems Accessing Local Files

    Hi,
    I'm sure this has been discussed before, but I'm havign problems accessing a file on the target machine's local filesystem. I've signed all my jars and added the all-permissions tag to the jnlp file. However, my code:
    ClassLoader cl = getClass().getClassLoader();
    InputStream is = cl.getResourceAsStream("c:/resources/testsuite.xml");
    fails to find the file "testsuite.xml".
    Is this a classpath issue? I've tried to add c:/resources to the class path but with no luck.
    any help would be much appreciated
    Thanks

    Try "file://c:/resources/testsuite.xml" instead. I
    believe you are suppose to be passing in a valid URL
    and what you passed in wasn't.That's wrong. Resource name should be just a path. It could be a full path started from "/" or just a relative path from given class (here better to use this.class.getResourceAsStream() method).
    Better yet, since you are giving full security access
    to the user's local machine you don't really need to
    rely on the class loader at all. It's just a normal
    file, so you could create your File object and read it
    in the way you do normally. I would suggest to do not rely on File object at all because it can only be dealing with local file system and thats can't be changed in future.

  • I cannot access PDF files from my current BT Yahoo...

    Since downloading an updated version of Yahoo Mail a few months ago, I cannot now access PDF files from old e-mail messages which are located in the "Folders" section on the mail screen.  When trying to open them the message "Scanning Attachments" is displayed.  After about 60 seconds a Message is displayed "An Error Occurred whilst Downloading". This never used to happen with the previous version of Yahoo Mail.  I have tried to save the attachments to my laptop and the message reads "Scanning Attachments" which would signify that they had been saved due to no subsequent Error Message being displayed.  I have trawled all through my laptop and cannot find any of the alleged saved PDF files.
    I am an old chap and not very computer literate and am hoping you professionals can come up with an answer and fix to this problem, which I believe, was not of my own making.
    Whether this has any bearing on the matter, I changed about four months ago from BT Total BB to Infinity Opt1 which includes McAfee security built in as standard.  I have also, as an on-screen reminder, recently updated my Adobe Reader programme to version 11.  I cannot think of any other changes, apart from the new version of Yahoo Mail, that has made this problem come to light as it has. 
    Your help and assistance in this matter would be most welcome and appreciated.
    Thanks You
    Ian.

    Your problem is typical of the many problems reported with McAfee, and that may well be the cause. McAfee is free with Infinity but isn't built-in in the sense that you have to take it. Is your previous anti-virus still installed? If so, you should get rid of one of them anyway, and the usual advice here would be to ditch McAfee.
    Even if McAfee is the your only AV I would replace it. If your previous AV is no longer available there are plenty of free options, and Microsoft Security Essentials (MSE) is as good a choice as any. There's advice on uninstalling McAfee here.
    You can click the white star next to this message if you think it was helpful.

  • How to access PC files from iPad

    How can I access PC files from my iPad?

    Depends on what kind of files. You have to have an app on your ipad that can open those files and share them.
    You can download the icloud control panel and use that on your pc.
    http://www.apple.com/icloud/setup/
    itunes also supports file sharing:
    To transfer files from your computer to your iPod touch, iPhone, or iPad:
    Connect your iPod touch, iPhone, or iPad to your computer.
    In iTunes, select your device (below Devices), and click the Apps button.
    Below File Sharing, select an app from the list, and click Add.
    In the window that appears, select a file to transfer, and click Choose.
    The file is transferred to your device, and can be opened in the app you selected in step 3.

  • I have a new Macbook pro and need to run some Windows software, it appears "Parallel" should work well from what I've have read. Will I have any issues or problems accessing and printing from various printers on my Windows 7 network within Parallel?

    I have a new Macbook pro and need to run some Windows software, it appears "Parallel" should work well from what I've have read. Will I have any issues or problems accessing and printing from various printers on my Windows 7 network within Parallel? Is Parallel in fact the best way to go?

    First, back up all data immediately, as your boot drive might be failing.
    There are a few other possible causes of generalized slow performance that you can rule out easily.
    Reset the System Management Controller.
    If you have many image or video files on the Desktop with preview icons, move them to another folder.
    If applicable, uncheck all boxes in the iCloud preference pane.
    Disconnect all non-essential wired peripherals and remove aftermarket expansion cards, if any.
    Check your keychains in Keychain Access for excessively duplicated items.
    If you have more than one user account, you must be logged in as an administrator to carry out this step.
    Launch the Console application in the same way you launched Activity Monitor. Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Select the 50 or so most recent entries in the log. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V). You're looking for entries at the end of the log, not at the beginning.
    When posting a log extract, be selective. Don't post more than is requested.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some personal information, such as your name, may appear in the log. Anonymize before posting. That should be easy to do if your extract is not too long.

  • How to display a dynamic image file from url?

    Hey,I want to display a dynamic image file from url in applet.For example,a jpg file which from one video camera server,store one frame pictur for ever.My java file looks like here:
    //PlayJpg.java:
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class PlayJpg extends Applet implements Runnable {
    public static void main(String args[]) {
    Frame F=new Frame("My Applet/Application Window");
    F.setSize(480, 240);
    PlayJpg A = new PlayJpg();
    F.add(A);
    A.start(); // Web browser calls start() automatically
    // A.init(); - we skip calling it this time
    // because it contains only Applet specific tasks.
    F.setVisible(true);
    Thread count = null;
    String urlStr = null;
    int sleepTime = 0;
    Image image = null;
    // called only for an applet - unless called explicitely by an appliaction
    public void init() {
                   sleepTime = Integer.parseInt(getParameter("refreshTime"));
              urlStr = getParameter("jpgFile");
    // called only for an applet - unless called explicitely by an appliaction
    public void start() {
    count=(new Thread(this));
    count.start();
    // called only for applet when the browser leaves the web page
    public void stop() {
    count=null;
    public void paint(Graphics g) {
    try{
    URL location=new URL(urlStr);
    image = getToolkit().getImage(location);
    }catch (MalformedURLException mue) {
                   showStatus (mue.toString());
              }catch(Exception e){
              System.out.println("Sorry. System Caught Exception in paint().");
              System.out.println("e.getMessage():" + e.getMessage());
              System.out.println("e.toString():" + e.toString());
              System.out.println("e.printStackTrace():" );
              e.printStackTrace();
    if (image!=null) g.drawImage(image,1,1,320,240,this);
    // called each time the display needs to be repainted
    public void run() {
    while (count==Thread.currentThread()) {
    try {
    Thread.currentThread().sleep(sleepTime*1000);
    } catch(Exception e) {}
    repaint(); // forces update of the screen
    // end of PlayJpg.java
    My Html file looks like here:
    <html>
    <applet code="PlayJpg.class" width=320 height=240>
    <param name=jpgFile value="http://Localhost/playjpg/snapshot0.jpg">
    <param name=refreshTime value="1">
    </applet>
    </html>
    I only get the first frame picture for ever by my html.But the jpg file is dynamic.
    Why?
    Can you help me?
    Thanks.
    Joe

    Hi,
    Add this line inside your run() method, right before your call to repaint():
    if (image != null) {image.flush();}Hope this helps,
    Kurt.

  • How to play .wav file from URL in web browser embed

    Hi;
    I want to play a .wav sound file in embed default media player in IE. Sound file is on some HTTP location. I am unable to sound it in that player.
    Following is the code.
    URL url = new URL("http://www.concidel.com/upload/myfile.wav");
            URLConnection urlc = url.openConnection();
            InputStream is = (InputStream)urlc.getInputStream();
             fileBytes = new byte[is.available()];
             while (is.read(fileBytes,0,fileBytes.length)!=-1){}
    BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
             out.write(fileBytes);Here is embed code of HTML.
    <embed src="CallStatesTreeAction.do?ivrCallId=${requestScope.vo.callId}&agentId=${requestScope.vo.agentId}" type="application/x-mplayer2" autostart="0" playcount="1" style="width: 40%; height: 45" />1. If I write in FileOutputStream then it plays well
    2. If I replace my code of getting file from URL to my local hard disk. then it also works fine.
    I don't know why I am unable to play file from HTTP. And why it plays well from local hard disk.
    Please help.

    You'll have to ask the devleopers of sencha and phonegap.

  • Weblogic call a excel-file from URL doesn't open MSExcel but flat html

    Weblogic call a excel-file from URL doesn't open MSExcel but flat html
    Hi,
    WLS 10.3.5
    Forms 11.1.1.4
    I do migrate from AS10g to WLS 10.3.5 / Forms 11
    I get differences between FORMS 10 g / AS and FORMS 11 / WLS
    when call an excel-file with web.showdocument
    in 10g AS10g
    the call
    web.showdocumen('http://MyAS10_Server/myFormsMapping/myExcelfile.xls, _blank);
    opens a Windows-Box
    to decide
    open with ( MSExcel )
    or
    download and save as File
    in WLS 10.3.5 / FORMS 11.1.1.4
    the call with webcache Port 8090 as well as Port OHS 8888
    web.showdocumen('http://MyWLS_Server:8090/myFormsMapping/myExcelfile.xls, _blank);
    opens promptly the excel-File into the Browser as html-Format
    How to get the same way under WLS as before in AS 10g,
    config OHS ?
    regards
    get answer here :
    Weblogic: when call a excelfile from URL doesn't open MSExcel but flat html
    Edited by: astramare on Sep 12, 2011 11:59 AM

    Weblogic: when call a excelfile from URL doesn't open MSExcel but flat html

  • Download file from URL using ADF (urgent help required)

    We have the following requirement:
    On clicking a button we need to download the file present at a particular location(we have the URL).
    I have written the following in .jspx file :
    <af:commandButton  id="btn1" >
                        <af:fileDownloadActionListener contentType="text/plain; charset=utf-8" method="#{bean.getFile}"/>
    </af:commandButton>
    The corresponding method in bean is :
    public void getFile(FacesContext facesContext, OutputStream outputStream) {
    HttpServletResponse response = null;
    ServletOutputStream ouputStream = null;
    currUrl = getFileURL("ID", 281);
    response =
    (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
    try {
    ouputStream = response.getOutputStream();
    ouputStream.write(this.getFileBytes(), 0,this.getFileBytes().length);
    ouputStream.flush();
    ouputStream.close();
    } catch (IOException ioe) {
    System.out.println("IO Exception");
    public byte[] getFileBytes() {
    URLConnection urlConn = null;
    InputStream iStream = null;
    URL url;
    byte[] buf;
    int byteRead;
    try {
    url= new URL("http://hjhj:34104/test.pdf");
    urlConn = url.openConnection();
    iStream = urlConn.getInputStream();
    buf = new byte[5000000];
    byteRead = iStream.read(buf);
    if (byteRead > 0) {
    System.out.println("Downloaded Successfully.");
    return buf;
    } catch (FileNotFoundException fnfe) {
    System.out.println("File not found Exception");
    fnfe.printStackTrace();
    } catch (Exception e) {
    System.out.println("Exception:" + e.getMessage());
    e.printStackTrace();
    } finally {
    try {
    iStream.close();
    } catch (IOException e) {
    System.out.println("IO Exception");
    e.printStackTrace();
    System.out.println("File");
    return null;
    The file is opening in same window but in some encrypted format. My requirement is to :
    1. Have a pop (as in Mozilla or IE) which asks if I want to save the file or open.
    2. Depending on that the file should be opened in pdf format and not in browser same window neither in browser tab.

    Jdev version : 11.1.2.1.0
    in .jspx file : we have a button. On clicking the button file from URL should be downloaded. I have used fileDownloadActionListener in commandButton. Corresponding code :
    <af:commandButton  id="btn1" >
                        <af:fileDownloadActionListener contentType="text/plain; charset=utf-8" method="#{bean.getFile}"/>
    </af:commandButton>
    in bean class : the method corresponding to fileDownloadActionListener is :
    public void getFile(FacesContext facesContext, OutputStream outputStream) {
         HttpServletResponse response = null;
         ServletOutputStream ouputStream = null;
         response =(HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
         try {
              ouputStream = response.getOutputStream();
              ouputStream.write(this.getFileBytes(), 0,this.getFileBytes().length);
              ouputStream.flush();
              ouputStream.close();
              } catch (IOException ioe) {
                   System.out.println("IO Exception");
    public byte[] getFileBytes() {
         URLConnection urlConn = null;
         InputStream iStream = null;
         URL url;
         byte[] buf;
         int byteRead;
         try {
              url= new URL("http://hjhj:34104/test");
              urlConn = url.openConnection();
              iStream = urlConn.getInputStream();
              buf = new byte[5000000];
              byteRead = iStream.read(buf);
              if (byteRead > 0) {
                   System.out.println("Downloaded Successfully.");
              return buf;   
        } catch (FileNotFoundException fnfe) {
              System.out.println("File not found Exception");
         } catch (Exception e) {
              System.out.println("IO Exception");
    The URL given in the code is for a file which can be a PDF file or an EXCEL file.
    My requirement is when i click the button:
    1. A pop should come (as in Mozilla or IE) which asks if I want to save the file or open.
    2. if i click on save file should save in a particular location.
    3. if i click on open it should open as PDF/EXCEL format and NOT in browser.
    Message was edited by: 1001638

  • Problem inporting raw files from my Nikon D3200

    i have problems importing raw files from my Nikon D3200, i have tried some of the suggestions such as
    removing the RawCamera.bundle and RawCameraSupport.bundle from the System Library and downloading a newer version (OS X Yosemite: Supported digital camera RAW formats - Apple Support)
    The problem is  --  the latest RAW Compatibility Update version for Yosemite 6.02 appears to be the one I currently am using (in my System Folder).
    In that same article referenced above, my Nikon D800 is listed in an earlier version simply titled "Supported by Yosemite 10.10".
    This had some success but is not working after trying it several times, i am currently on version  OSX Yosemite 10.10.1 and the version of iphoto is 9.6
    any help would be greatly received as i only shoot in Raw

    Remove the RawCamera.bundle and RawCameraSupport.bundle again and update the system to 10.10.2 via the App Store.  That contains the bundles that will support that camera: OS X Yosemite: Supported digital camera RAW formats - Apple Support.  The 6.01 and 6.02 updates are not needed for that camera. Be sure to repair disk permissions after the update.
    As usual be sure you have a backup of your hard drive before applying any such update.

  • I have LR2 but not able to access nef files from my Nikon D800

    Unable to access nef files from my Nikon D800.

    You need Lightroom 4.1 or later (the current version is 5.7.1 but will not run on Windows Vista or XP and certain Mac operating systems, if that's an issue)
    You could also download the FREE Adobe DNG Converter version 7.1 or later and convert your RAWs to DNG and import those into your Lightroom 2.

Maybe you are looking for

  • Drop down not working in ie8

    Hi and thanks in advance for any help you can provide. I have a site http://www.webworksnow3.com/src id:src, pwd:src12345.  There is a spry horizontal menu and a spry vertical menu on the pages under "About Us".  When on one of the children pages wit

  • Passing between date paramters to a different page in the application

    Hi, I'm woking on a drill down report in Apex 4.0. Page1: (standard Report) select transactiondate, storenumber, count(amount) as Count from transactions (transactiondate data type is DATE). Created two items :P1_From_Date and :P1_To_Date When i run

  • Error message appears and disappears before I can read it?

    I have a message that pops up and disappears before I can get a chance to read it. I figured it may be an issue with an application since MS office 11 is installed and was running at the times also, before a reminder pops up a message appears. I fear

  • I deleted my messages by accident and haven't backed up my files

    Help! MY boyfriend is leaving for the army and I delted his messages and I haven't backed up my messages on my phone.

  • Just purchased an iWork 08 Serial Number won't work

    I ordered an iWork 08 Serial Number Family Pak. Why because I still use OSX.4.11. (an not use iWork09 as my machines are PowerPC. However in trying to enter serial number will not work. in clicking order details the sent me a serial number for 09. an