My output file is empty.

I'm reading the content of several .txt files in the same diretory and create a .txt file containing all the data of each file in the program below.

My output is generated in the console but my .text file is empty.

 

Public Shared Sub main (String [] args) throws IOException {}

String target_dir = "C:\\Files";

Line = "C:\\Files\\output.txt";

File dir = new File (target_dir);

File files [] = dir.listFiles ();

Open the Printwriter before your loop

PrintWriter OutputStream = new PrintWriter (output);

close the outputstream after the loop

outputStream.close ();

try {}

inputStream = new BufferedReader (new FileReader (textfiles));

String line;

While ((line = inputStream.readLine ())! = null) {}

System.out.println (Line);

Write content

outputStream.println (line);

}

} {Finally

If (inputStream! = null) {}

inputStream.close ();

}

}

}

If (outputStream! = null) {}

outputStream.close ();

}

}

}

}

Post edited by: 2801625 I've made changes to empty and close the output stream.

Looks like your outputstream.close () is always inside the loop for.

Please, align your code correctly and check the braces of the closing the loop for.

The code below should be outside the loop for.

if (outputStream != null) {
  outputStream.close();
  }

So basically what had happened after writing the contents of the first file, the output stream closed.

See you soon

AJ

Tags: Java

Similar Questions

  • Web Services and BEEP 10.1.3.4.0 - output file is empty to the customer

    Hi all

    We used SUCCESSFUULY the TONE WebServiceAPI with JDeveloper to create a Proxy Stub described in this paper: http://www.oracle.com/technology/products/xml-publisher/docs/Forms_BIP_v21.pdf.
    BEEP 10.1.3.3.2
    JDeveloper 10.1.3.3

    We want to move away from Oracle reports and use BEEP as a tool of reporting for all of our Oracle Form applications. Ideally, we would like to use the latest version of the tool (10.1.3.4.0).

    However, we are unable to do the same thing in the last version of BEEP (10.1.3.4). The release of the files downloaded to the client have 0 bytes (empty). We have currently debugging the issue and the report actually runs and output is generated on the BI server but not read by the service. The same code works with older BEEP (10.1.3.3.2) the only difference that I can tell is the BEEP Server version and of course the service wsdl corresponding.

    We contacted the Support of Oracle, but they say that this type of integration problems are not supported (IE contact Oracle Consulting). Does anyone else have problems using PublicReportService (WSDL created by Apache Axis version: 1.4, built on April 22, 2006 (06: 55:48 PDT)?)

    Thanks in advance for your time.

    Yahya

    on page 15 of the document, add the following line
    repRequest.setSizeOfDataChunkDownload(-1);

  • I downloaded the bridge output module and copied the files to the correct location but the output pane remains empty

    I downloaded the bridge output module to create contact sheets and copied the files to the correct location, but the output pane remains empty.

    I removed and replaced the files including the! $AdobeOutputModule file $ but still no luck...

    I have reset the workspaces, preferences...

    How can I completely remove it and start again?

    Thanks in advance!

    Settled myself

  • write table 2D data in the file but the file is empty

    Hello

    I tried to write all reading of powermeter data to a file in two ways, I can see the output in the Arrais indicator data but when I write to "File.vi of the worksheet" or write to 'text file', the files are empty.

    Please help me.

    Try to remove the vi "STOP".

    I suspect, it prevents the main vi before the backup occurs.

    As a second point: given that you save data inside a while loop be sure you add the data from the file and not crash each time.

    wire that is a 'real' terminal 'Add file '.

    Kind regards

    Marco

  • Excel file is empty when the burst!

    Hi all

    RDBMS: 11.2.0.3.0

    Oracle Applications: 12.1.3

    I'm new to break and I'm having a problem.  When my output type is Excel the file attached to the email is completely empty!  If I just change the type of output to PDF, my data is here!

    Anyone know what is happening here?

    Here's my break control file, I have some data for a sanitized public viewing...

    Any help is greatly appreciated!

    {code}

    <? XML version = "1.0" encoding = "UTF-8"? >

    " < = xmlns:xapi xapi:requestset ' http://xmlns.Oracle.com/OXP/XAPI "type ="break"> "

    < select xapi:request = ' / MWACIIER/LIST_G_INTERFACE_CONTROL/G_INTERFACE_CONTROL/LIST_G_ERRORS/G_ERRORS ">

    < xapi:delivery >

    < xapi:email server = "00.000.0.00" port = "25".

                         from=" [email protected] "RΘpondre α =" [email protected] ">

    " < xapi:message id ="123"to =" ' [email protected] 'cc =' "attachment = 'true' content-type 'text' subject = 'Test out' = >

    < body >

    The error report is attached ready for you to review. < br / > < br / >

    Text here! < br / >

    More text here! < br / >

    < / body >

    < / xapi:message >

    < / xapi:email >

    < / xapi:delivery >

    < output = xapi:document "test2.xls" output-type = "excel" delivery = "123" > "

    "< xapi:template type ="rtf"location="/ua4001/oracle/MFSGUAT/apps/apps_st/appl/xbol/12.0.0/xml/MWACIIER.rtf "> < / xapi:template >

    < / xapi:document >

    < / xapi:request >

    < / xapi:requestset >

    {code}

    Here's my problem, it's related to the messaging tool that I use to watch the attachment...

    You use Microsoft Outlook Web Access (OWA) 2007 access one
    mailbox on a computer that is running Microsoft Exchange Server 2007 Service
    Pack 1. When you download a .xls file attachment and then try to open the
    file, the downloaded file is empty.

    This problem occurs if the .xls file contains XML data. In
    Exchange Server 2007, if a file that contains the XML data is associated with a
    message, the XML content in the file is removed when you open or save it
    attachment using OWA.

    To resolve this problem, install the update rollup 6 for Exchange
    2007 service Pack 1.

    For more information about the update rollup 6 for Exchange Server 2007 Service
    Pack 1, see the following Exchange Help topic:

    Description of
    The update rollup 6 for Exchange Server 2007 Service Pack 1

    ( http://go.microsoft.com/fwlink/?LinkId=152555)

    For more information on how to get the last Exchange
    service pack or update rollup, see the following Exchange Help topic:

  • Contacts file is empty after the last OS update.  I have a backup, but what is the name of file

    I have a backup, but what is the name of the contacts file so that I can restore the backup?  After that the last operating system updated, the contacts file is empty.

    If you use Time Machine for backup, you can open the app on your Mac and then click the Time Machine icon in the menu bar and then click on "Enter Time Machine".

  • "Extraction failure: cannot open output file" error message when installing new drivers

    Hello, I am trying to install new drivers for my HP Photosmart C4385 printer.  I downloaded the complete drivers of features for Windows XP 32-bit, and when I start to install (extract), I get the error message:

    Extraction failed

    Cannot open output file

    And the process ends.  He arrived at about 85% extraction every time.

    No idea why?  I called HP, but no longer under warranty they wanted money, which I think as absolutely ridiculous - not even give me basic support?  Poor, poor customer service.

    Hi GIJeff12,

    Temporarily disable any AntiVirus/Antispyware software.

    Cut the installer on your desktop then click on the Start Menu, click computer, double-click on the C: drive and paste the installler here.  Now try a right click on the installer for your printer, choose 7-Zip and choose Extract the files, and then click Ok.  If the installation program extracts now correctly, follow these steps.  If it does not extract, let me know.

    Disconnect your printer from the PC.  Restart your PC.

    Open the newly extracted folder and double-click the setup application to start the installation (the installation application will probably have the same icon as the original installation software that you downloaded).  Connect the printer to your computer when you are asked.

    If it was a success, re - enable your security software.

    Best wishes

    DP - K

  • I just tried to update Firefox to version 9.0.1. Extract of 13%, and then I got an error message cannot open output file. Can you help me please?

    I just tried to update Firefox to version 9.0.1. Extract of 13%, and then I got the error message cannot open output file.

    The file can be uploaded incorrectly. Could you it redownload again from http://getfirefox.com?

  • When I try to install Firefox, I get an error "could not open the output file. I used Firefox before and it doesn't work anymore, so I uninstalled. Cannot re - install now.

    When I try to install Firefox, I get an error "could not open the output file. I used Firefox before and it doesn't work anymore, so I uninstalled. Cannot re - install now.

    This has happened

    Each time Firefox opened

    I tried to download firefox.

    User Agent

    Mozilla/4.0 (compatible; INTERNET EXPLORER 6.0; Windows NT 5.1; SV1; AntivirXP08; GTB6.3; .NET CLR 2.0.50727; MS - RTC LM 8)

    When you click on the download link on GetFirefox.com, you should be asked if you want to run or save the file. If this situation occurs when you try to run the download, try instead to record and put the file on your desktop or in a similar place, where you are certain that you can find.

    When the download is complete, try double-clicking on the downloaded file in the normal Windows Explorer (browse your way to the file from the desktop). This should start the installation.

    If, in the Explorer window, you notice that the file seems to be missing the Firefox icon orange/blue, right click the file and select Properties. The image should look like the attached picture (except that mine is in Danish, but that is irrelevant) if saved correctly - if it don't look like this, would you please describe the content or attach a screenshot of the box. Especially what it says under "File Type" - it must be 'program '. If this isn't the case, will have to focus on what could be the problem here.

    A bit off-topic, your Internet Explorer seems to be quite a bit outdated (IE 6, where the current version is IE 8), so I highly recommend that you try to run Windows Update to get your system up to date. Is it as a society (such as a thin client Terminal Server computer) system, this is not possible, and most likely, your system administrator will have to help you.

  • R7000 vpn client.crt file is empty

    My version is 1.0.4.30_1.1.67.

    After you generate files of VPNs, client.crt file is empty 0 byte.

    The other files are correct.

    Can anyone help?

    Thank you.

    Hi @jli

    Welcome to the community!

    Try to use the latest beta of firmware 1.0.5.60.

  • How the names of variables and units used in the binary output file

    My colleague will give me LabView generated from the binary files (*.dat). There are more than 60 variables (columns) in the binary output file. I need to know the names of variables and units, which I think he has already configured in LabView. Is there a way for him to produce a file that contains the name of the variable and unity, so that I'll know what contains the binary file? It can create an equivalent ASCII file with a header indicating the name of the variable, but it does not list the units of each variable.

    As you can tell I'm not a user of LabView, so I apologize if this question makes no sense.

    Hi KE,.

    an ASCII (probably the csv format) file is just text - and contains all data (intentially) written to. There is no special function to include units or whatever!

    Your colleague must save the information it records the names and values in the same way...

    (When writing to text files, it could use WriteTextFile, FormatIntoFile, WriteToSpreadsheetFile, WriteBinaryFile even could serve...)

  • I had to reinstall the operating system after that Itried to restore my files for the backup that I had already taken in an external drive, the problem is tha files are empty?

    When I am trying to restore my file that I can't reach them, in some cases I can read the name of the file such as the name of a singer, but when I tried to open the file is empty, he said. This happens with my contact and all my media. I lose my stuff.

    [Moved from comments]

    Hi Hector.

    1. what version of Windows operating system is installed on your computer?

    2. you use software to perform the system backup and restore?

    3 is the issue limited to any particular file?

    First of all, I suggest you click with the right button on the backup files and check the size of the file in the Properties window.

    Try to copy and paste the files to the computer and check if you are able to access the files.

    You can also check if the folders are hidden. If the folders are hidden, so you can view folders and check if you are able to access the data.

    1. press the ALT key on the keyboard in any Windows Explorer window to display the toolbar.
    2. click on tools, then Options of folders, and then on the view tab.
    3. then choose "show files and folders". After clicking OK, they appear with the other files.

    Hope that the information provided is useful.

  • several pages scanned in an output file

    I have a 8600 and use the HP scanning software.  I want to do multiple scans and include those in an output file.  If the media keeps me using the auto feed printer, how can I do this?  A scanning software different HP that I had previously used an option that asked if I wanted to add additional pages.  I don't see this option on this software.

    Thank you

    You are welcome

    As I mentioned, it occurs due to memory limitations the software...

    Several pages in higher resolutions of transformation is too important resources for the HP scanning software and therefore unsupported...

  • What is a "name of output file?

    Suddenly, if I want to print from a PDF file, box a little "print to a file" appears and asks for the "output file name".  What is c?  I tried to put in the name of the PDF, or the printer info, or just do something.  Nothing works.  What is - this and what he seeks?  I never used to see this.

    Print to a file means it's going to save it to a location such as My Documents, and he wants that tell you it where to save it. These print preferences you need to adjust your printer. Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • output file missing error

    windows xp ser pk 3 starts I get missing output file in the dynamic library. Can someone tell me how to fix this problem. I can't find an answer anywhere.

    Something is apparently from Windows and failing. You should know that something is and troubleshoot accordingly.

    Start > run > msconfig [Enter]

    This will open the System Configuration utility. Look under the Startup tab and find the likely culprit. Uncheck the box next to its name, apply and OK out. You don't need to restart immediately, but next time you do, you will get a dialog box saying that you have used the utility. Just check the box that says in effect, "don't mind to this subject again".

    Important - do not use the System Configuration utility to stop the process. Use rather Start > Run > services.msc [Enter] and stop all services unless you really, really know what you're doing.

    How to troubleshoot by using the Msconfig in Windows XP utility - http://support.microsoft.com/?id=310560
    The free Autoruns program is very useful for managing your Startup - http://www.microsoft.com/technet/sysinternals/default.mspx MS - MVP - Elephant Boy computers - Don ' t Panic!

Maybe you are looking for