Writing to file(using PrintWrier)

Im trying to do a simple program that will write system information into a file for data basing.
But the problem is it creates the file but does not write anything ive used other methods. But they would
not let me write to a new line in the .dat file. Im looking for a quick and easy solution. Help is appreciated
import java.io.*;
import java.util.*;
public class MLS_writer {
     public static void main(String args [] ) {
     try{
          PrintWriter out = new PrintWriter(new FileWriter("C:\\bank.dat"));
          // make file writer
               out.println("USER DATA");
               out.println("User name=");
               String getinput;
               System.out.println("Enter the account your currently logged in on");
               Scanner getin = new Scanner(System.in);
               getinput =     getin.next();
               out.println(getinput);
               //out.println ("\n");
               //out.println("Computer operationg sysetm=");
               System.out.println("Enter computer operating system.");
               String osinput;
               osinput = getin.next();
               out.println("operationg system=" + osinput);
               //out.write("\n");
               out.println("Command line/shell=default");
               //out.write("\n");
               }catch (Exception e) {
                    System.out.println("Error: " + e.getMessage());
                    System.out.println("Unable to write file Mbank.dat");
}

i figured it out i didn't close the stream! thanks anyway!

Similar Messages

  • "encoding = UTF-8" missing while writing XML file using file Adapter

    Hi,
    We are facing an unique problem writing xml file using file adapter. The file is coming without the encoding part in the header of xml. An excerpt of the file that is getting generated:
    <?xml version="1.0" ?>
    <customerSet>
    <user>
    <externalID>51017</externalID>
    <userInfo>
    <employeeID>51017</employeeID>
    <employeeType>Contractor</employeeType>
    <userName/>
    <firstName>Gail</firstName>
    <lastName>Mikasa</lastName>
    <email>[email protected]</email>
    <costCenter>8506</costCenter>
    <departmentCode/>
    <departmentName>1200 Corp IT Exec 8506</departmentName>
    <businessUnit>1200</businessUnit>
    <jobTitle>HR Analyst 4</jobTitle>
    <managerID>49541</managerID>
    <division>290</division>
    <companyName>HQ-Milpitas, US</companyName>
    <workphone>
    <number/>
    </workphone>
    <mobilePhone>
    <number/>
    </customerSet>
    </user>
    So if you see the header the "encoding=UTF-8" is missing after "version-1.0".
    Do we need to configure any properties in File Adapter?? Or is it the standard way of rendering by the adapter.
    Please advice.
    Thanks in advance!!!

    System.out.println(nodeList.item(0).getFirstChild().getNodeValue());

  • Reading/Writing .xlsx files using Webdynpro for Java

    Dear All
    I have a requirement to read/write excel files in .xlsx format. I am good in doing it with .xls format using jxl.jar. The jxl.jar doesn't support .xlsx format. Kindly help me in understanding how do I need to proceed on reading/writing .xlsx files using Webdynpro for Java.
    Thanks and Regards
    Ramamoorthy D

    i am using jdk 1.6.22 and IBM WebSphere
    when i use poi-3.6-20091214.jar and poi-ooxml-3.6-20091214.jar  to read .xlsx file. but i am getting following errors
    The project was not built since its classpath is incomplete. Cannot find the class
    file for java.lang.Iterable. Fix the classpath then try rebuilding this project.
    This compilation unit indirectly references the missing type java.lang.Iterable
    (typically some required class file is referencing a type outside the classpath)
    how can i resolve it
    here is the code that i have used
    public class HomeAction extends DispatchAction {
         public ActionForward addpage(
                             ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
                             throws Exception {     
                             String name = "C:/Documents and Settings/bharath/Desktop/Book1.xlsx";
               FileInputStream fis = null;
               try {
                   Object workbook = null;
                    fis = new FileInputStream(name);
                    XSSFWorkbook wb = new XSSFWorkbook(fis);
                    XSSFSheet sheet = (XSSFSheet) wb.getSheetAt(0);
                    Iterator rows = sheet.rowIterator();
                    int number=sheet.getLastRowNum();
                    System.out.println(" number of rows"+ number);
                    while (rows.hasNext())
                        XSSFRow row = ((XSSFRow) rows.next());
                        Iterator cells = row.cellIterator();
                        while(cells.hasNext())
                    XSSFCell cell = (XSSFCell) cells.next();
                    String Value=cell.getStringCellValue();
                    System.out.println(Value);
               } catch (IOException e) {
                    e.printStackTrace();
               } finally {
                    if (fis != null) {
                         fis.close();
                return mapping.findForward("returnjsp");

  • Writing word file using POI

    HI!
    can any body help me in writing a new word file using Apache POI (Java API). any code or link.
    Thanks in advance

    http://poi.apache.org/hwpf/quick-guide.htmland
    http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/

  • Reading/writing PDF files using JAVA

    how to read/write a PDF file using java,
    while i read a pdf file using BUfferedReader class it gives a list of char. which is not readable.
    how to convert those files to readable format.?
    is there any special class for doin that.?
    plz explain..?

    is there any special class for doin that.?Yes, I'm sure Google knows a few libraries that ca do that.

  • Memory issues writing binary files, using a subVI to do all File Handling, topVI, when run normally files are way too large.

    Problem writing binary files with LV 8.5. I have one VI that does all the interaction/file I/O and another VI for testing. I find when I run the subVI where all the data reading/writing is happening with break points and single stepping through the code all is OK, but when I run normally the files are much larger than they should be and as well when I close the files I get a error. Any insights?  
    Walter

    Waltz wrote:
    I found the problem, I was actually trying to close the files twice.
    I don't see how this could cause the symptoms you described in the first post.
    (It only explains the error on close).
    LabVIEW Champion . Do more with less code and in less time .

  • Problem writing xml file using DOM

    Hi,
    I am trying to write a xml file using DOM. I am using xalan 2.5, xerces 1.4.4, jdk 1.3.1 in JRun 3 on windows.
    The code where I get exception :
                   TransformerFactory tFactory = TransformerFactory.newInstance();
                   Transformer transformer = tFactory.newTransformer();
                   transformer.transform(new DOMSource(doc), new StreamResult("pr.xml"));
    I get the runtime error as follows:
    javax.servlet.ServletException: null
    java.lang.NoSuchMethodError
         at org.apache.xml.utils.DOM2Helper.getNamespaceOfNodeDOM2Helper.java:342)
         at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java:387)
         at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java:202)
         at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:343)
    Thinking it is because of classpath, I placed xalan 2.5, xerces 1.4.4 jar files in jrun admin lib directory and in server lib directory as well. Still getting the same error.
    Any suggestion?
    Thanks in advance

    xalan is included in JRun 4. However JRun 3 does not.
    However I tried with the same code in JRun3 in different system. The error is completely different. I understand this is because of different version of files. trying to solve ;)
    Here my new exception
    javax.servlet.ServletException: org/w3c/dom/ranges/DocumentRange
    java.lang.NoClassDefFoundError: org/w3c/dom/ranges/DocumentRange
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
         at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source)
         at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
         at com.cybell.appl.deliveryorder.cmd.CreateXMLDOFile.createFile(CreateXMLDOFile.java:73)
         at com.cybell.appl.deliveryorder.cmd.CreateXMLDOFile.execute(CreateXMLDOFile.java:36)
         at com.cybell.appl.framework.cmd.BaseCommand.start(BaseCommand.java:50)
         at com.cybell.appl.framework.control.BaseController.service(BaseController.java:38)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
         at allaire.jrun.servlet.JRunNamedDispatcher.forward(../servlet/JRunNamedDispatcher.java:34)
         at allaire.jrun.servlet.Invoker.service(../servlet/Invoker.java:84)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
         at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:88)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1131)
         at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:330)
         at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:107)
         at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
         at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)

  • Writing the file using Write to SGL and reading the data using Read from SGL

    Hello Sir, I have a problem using the Write to SGL VI. When I am trying to write the captured data using DAQ board to a SGL file, I am unable to store the data as desired. There might be some problem with the VI which I am using to write the data to SGL file. I am not able to figure out the minor problem I am facing.  I am attaching a zip file which contains five files.
    1)      Acquire_Current_Binary_Exp.vi -> This is the VI which I used to store my data using Write to SGL file.
    2)      Retrive_BINARY_Data.vi -> This is the VI which I used to Read from SGL file and plot it
    3)      Binary_Capture -> This is the captured data using (1) which can be plotted using (2) and what I observed is the plot is different and also the time scare is not as expected.
    4)      Unexpected_Graph.png is the unexpected graph when I am using Write to SGL and Read from SGL to store and retrieve the data.
    5)      Expected_Graph.png -> This is the expected data format I supposed to get. I have obtained this plot when I have used write to LVM and read from LVM file to store and retrieve the data.
    I tried a lot modifying the sub VI’s but it doesn’t work for me. What I think is I am doing some mistake while I am writing the data to SGL and Reading the data from SGL. Also, I don’t know the reason why my graph is not like (5) rather I am getting something like its in (4). Its totally different. You can also observe the difference between the time scale of (4) and (5).
    Attachments:
    Krishna_Files.zip ‏552 KB

    The binary data file has no time axis information, it is pure y data. Only the LVM file contains information about t(0) and dt. Since you throw away this information before saving to the binary file, it cannot be retrieved.
    Did you try wiring a 2 as suggested?
    (see also http://forums.ni.com/ni/board/message?board.id=BreakPoint&message.id=925 )
    Message Edited by altenbach on 07-29-2005 11:35 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Retrive_BINARY_DataMOD2.vi ‏1982 KB

  • Error while writing to file using UTL_FILE

    I've created below mentioned directory object and also granted the user appdevnew the appropriate previleges under SYSTEM user. Before giving this command, i've manually created the folder in c drive and created myspool.log file manually. Is it needed or can be created programmatically?
    CREATE DIRECTORY mydir AS 'C:\mydir';
    GRANT READ,WRITE ON DIRECTORY MYDIR TO appdevnew;
    Then logged into appdevnew and ran the block below. But i had been shown with error code ora-29280.
    DECLARE
    hnd UTL_FILE.FILE_TYPE;
    BEGIN
    hnd := UTL_FILE.FOPEN ('mydir', 'myspool.log', 'w',80);
    UTL_FILE.PUT_LINE (hnd, 'Some text here..', TRUE);
    UTL_FILE.FCLOSE (hnd);
    END;
    /

    Hi,
    It's a common problem, people think utl_file can see their PC's, whereas in fact the code runs on a server sometimes miles away and has no clue about your PC! You aren't the first and you won't be the last either.
    As for creating a directory, I take it you mean to somehow issue 'mkdir' or the equivalent to create an OS level directory (or Folder, as this is Whinedoze) on the server? You have to be careful with terminology here, because people will think (and quite rightly to) that you are referring to directory objects which utl_file now uses.
    There is no native way of doing this in PL/SQL. You can if you wish write a java stored procedure which then gives you this ability inside PL/SQL. However, I would question the need to actually dynamically create OS directories. Better do it just once for setup and be done. Less moving parts, less headaches.
    And I don't know what you mean by the file extension at all. You opened a file with the extension .log so that's what you will get. If you somehow asked utl_file to open a file called myspool.log and you ended up with myspool.txt this would be a bug and you had best log this with Oracle Support. However, if you are somehow confusing the file extension (a naming convention foisted on us by Micro$oft) with the actual contents of a file (plain text ascii or binary) then the answer is, in 9i, utl_file only gives you the abilty to write text files. Writing binary is available in 10g.
    There are workarounds to write binary files in 9i.
    HTH
    Chris
    Message was edited by:
    Chris Poole (because I can't spel)
    Message was edited by:
    Chris Poole (still can't spel)

  • Writing to file using PrintStream and PrintWriter...

    I tried to write a string to a file, it actually ADD the string to the bottom of the text file without deleting what was already in there. at first I use PrintStream, it worked fine when run it from my MS-J++6.0, but it says "PrintStream has been deprecated by the author of java.io.printstream", and when I try to run it from IE it doesn't even work. then I look into the MSDN, it says jdk 1.1 prefer to use PrintWritier, so I change it to PrintWriter, no more error message but now the file only records the last string I entered and deleted all the text I had in there before. and it still doesn't work when I try to run it from IE. And for some reason, the program will creat the text file on my desktop(winXP) instead in the same folder where the java files are....
    Please help me understand what's wrong and how to solve it.. thank you. here is my code...
    public void storing(String msg)
              PrintWriter ps = null;
              try
                   ps = new PrintWriter(new FileOutputStream("collect.txt"), true);
                   ps.println(msg);
              catch (IOException e)
                   feedback.append("Cannot write to file.");
              finally
                   if(ps != null)
                        ps.close();

    cuz what I am doing is to have the user input 30 lines of messages, each time a message is written, they press a "next" button then that line of message will be saved to file, then the user can write the next line. I do this becuz I am affraid that the user will close the applet before he finishes all 30 line, if he does that, I still want to get as much line that the user has wrote that's why I have it write to file each time a line is written. So if I open a file at the beginning of the program, will it encounter any problem if the user close the applet without close the file??
    thanx.

  • Reading & writing to file using ArrayList String incorrectly

    Hi Java Experts,
    I am running out of ideas on why my findSnomedCodes.java program is filling up the output file (Snomed-Codes.txt) with the
    same information ([M44110|T33010, , M92603|T10350, ]) continuously. This program goes through a dummy patient result file
    and pickup the 3rd line of each record and insert it into an ArrayList of String before writing it into a Snomed-Codes.txt
    file. A followed up method prints out everything from Snomed-Codes.txt.
    Below is the source code of findSnomedCodes.java program:
    import java.io.*;
    import java.io.IOException;
    import java.lang.String;
    import java.lang.Character;
    import java.util.regex.*;
    import java.util.ArrayList;
    import java.util.List;
    public class FindSnomedCode {
    static List<String> complete_records = new ArrayList<String>();
    static public void getContents(File existingFile) {
    StringBuffer contents = new StringBuffer();
    BufferedReader input = null;
    int line_number = 0;
    int number_of_records = 0;
    String snomedCodes = null;
    try {
    input = new BufferedReader( new FileReader(existingFile) );
    String current_line = null;
    while (( current_line = input.readLine()) != null) {
    // Create a pattern to match for the "\"
    Pattern p = Pattern.compile("\\\\");
    // Create a matcher with an input string
    Matcher m = p.matcher(current_line);
    boolean beginning_of_record = m.find();
    if (beginning_of_record) {
    line_number = 0;
    number_of_records++;
    } else {
    line_number++;
    if (line_number == 2) {
    snomedCodes = current_line;
    System.out.println(snomedCodes);
    complete_records.add(current_line);
    catch (FileNotFoundException ex) {
    ex.printStackTrace();
    catch (IOException ex){
    ex.printStackTrace();
    finally {
    try {
    if (input!= null) {
    input.close();
    catch (IOException ex) {
    ex.printStackTrace();
    static public void setContents(File reformatFile, List snomedCodes)
    throws FileNotFoundException, IOException {
    Writer output = null;
    try {
    output = new BufferedWriter( new FileWriter(reformatFile) );
    while (snomedCodes.iterator().hasNext())
    output.write( snomedCodes.toString() );
    finally {
    if (output != null) output.close();
    static public void printContents(File existingFile) {
    //...checks on existingFile are elided
    StringBuffer contents = new StringBuffer();
    BufferedReader input = null;
    int line_number = 0;
    int number_of_records = 0;
    long total_number_of_lines = 0;
    String snomedCodes = null;
    try {
    input = new BufferedReader( new FileReader(existingFile) );
    String current_line = null;
    while (( current_line = input.readLine()) != null)
    System.out.println(current_line);
    catch (FileNotFoundException ex) {
    ex.printStackTrace();
    catch (IOException ex){
    ex.printStackTrace();
    finally {
    try {
    if (input!= null) {
    input.close();
    catch (IOException ex) {
    ex.printStackTrace();
    public static void main (String args[]) throws IOException {
    File currentFile = new File("D:\\AP Data Conversion\\1988\\dummy_test_records.txt");
    getContents(currentFile);
    File snomedFile = new File( "D:\\AP Data Conversion\\1988\\Snomed-Codes.txt");
    setContents(snomedFile, complete_records);
    printContents(snomedFile);
    The output from Netbeans/Java is as follows:
    M44110|T33010
    M92603|T10350
    Exception in thread "main" java.io.IOException: There is not enough space on the disk
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:260)
    at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
    at sun.nio.cs.StreamEncoder$CharsetSE.implClose(StreamEncoder.java:427)
    at sun.nio.cs.StreamEncoder.close(StreamEncoder.java:160)
    at java.io.OutputStreamWriter.close(OutputStreamWriter.java:222)
    at java.io.BufferedWriter.close(BufferedWriter.java:250)
    at FindSnomedCode.setContents(FindSnomedCode.java:90)
    at
    FindSnomedCode.main(FindSnomedCode.java:134)---------------------------------------------------------------------------------
    The content of Snomed-Codes.txt file is filled with continuous lines of [M44110|T33010, , M92603|T10350, ] as follows:
    [M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, ,
    M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350,
    ][M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, ,
    M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350, ][M44110|T33010, , M92603|T10350,
    I must have done something wrong with the ArrayList.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    while (snomedCodes.iterator().hasNext())
      output.write( snomedCodes.toString() );
    }Here you have some kind of a list or something (I couldn't stand to read all that unformatted code but I suppose you can find out). It has an iterator which gives you the entries of the list one at a time. You keep asking if it has more entries -- which it does -- but you never get those entries by calling the next() method, so it always has all the entries still available.
    And your code inside the loop is independent of the iterator, so it's rather pointless to iterate over the entries and output exactly the same data for each entry. Even if you were iterating correctly.

  • Reading & writing to file using ArrayList String incorrectly (2)

    I have been able to store two strings (M44110|T33010, M92603|T10350) using ArrayList<String>, which represent the result of some patient tests. Nevertheless, the order of these results have been stored correctly.
    E.g. currently stored in file Snomed-Codes as -
    [M44110|T33010, M92603|T10350][M44110|T33010, M92603|T10350]
    Should be stored and printed out as -
    M44110|T33010
    M92603|T10350
    Below is the detail of the source code of this program:
    import java.io.*;
    import java.io.IOException;
    import java.lang.String;
    import java.util.regex.*;
    import java.util.ArrayList;
    public class FindSnomedCode {
        static ArrayList<String> allRecords = new ArrayList<String>();
        static public ArrayList<String> getContents(File existingFile) {
            StringBuffer contents = new StringBuffer();
            BufferedReader input = null;
            int line_number = 0;
            int number_of_records = 0;
            String snomedCodes = null;
            ArrayList<String> complete_records = new ArrayList<String>();
            try {
                input = new BufferedReader( new FileReader(existingFile) );
                String current_line = null;
                while (( current_line = input.readLine()) != null) {
                    // Create a pattern to match for the "\"
                    Pattern p = Pattern.compile("\\\\");
                    // Create a matcher with an input string
                    Matcher m = p.matcher(current_line);
                    boolean beginning_of_record = m.find();
                    if (beginning_of_record) {
                        line_number = 0;
                        number_of_records++;
                    } else {
                        line_number++;
                    if ( (line_number == 2) && (current_line.length() != 0) ) {
                        snomedCodes = current_line;
                        System.out.println(snomedCodes);
                        complete_records.add(current_line);
            catch (FileNotFoundException ex) {
                ex.printStackTrace();
            catch (IOException ex){
                ex.printStackTrace();
            finally {
                try {
                    if (input!= null) {
                        input.close();
                catch (IOException ex) {
                    ex.printStackTrace();
            return complete_records;
        static public void setContents(File reformatFile, ArrayList<String> snomedCodes)
                                     throws FileNotFoundException, IOException {
           Writer output = null;
            try {
                output = new BufferedWriter( new FileWriter(reformatFile) );
                  for (String index : snomedCodes) {
                      output.write( snomedCodes.toString() );
            finally {
                if (output != null) output.close();
        static public void printContents(File existingFile) {
            StringBuffer contents = new StringBuffer();
            BufferedReader input = null;
            int line_number = 0;
            int number_of_records = 0;
            String snomedCodes = null;
            try {
                input = new BufferedReader( new FileReader(existingFile) );
                String current_line = null;
                while (( current_line = input.readLine()) != null)
                    System.out.println(current_line);
            catch (FileNotFoundException ex) {
                ex.printStackTrace();
            catch (IOException ex){
                ex.printStackTrace();
            finally {
                try {
                    if (input!= null) {
                        input.close();
                catch (IOException ex) {
                    ex.printStackTrace();
        public static void main (String args[]) throws IOException {
            File currentFile = new File("D:\\dummy_patient.txt");
            allRecords = getContents(currentFile);
            File snomedFile = new File( "D:\\Snomed-Codes.txt");
            setContents(snomedFile, allRecords);
            printContents(snomedFile);
    }There are 4 patient records in the dummy_patient.txt file but only the 1st (M44110|T33010) & 3rd (M92603|T10350) records have results in them. The 2nd & 4th records have blank results.
    Lastly, could someone explain to me the difference between java.util.List & java.util.ArrayList?
    I am running Netbeans 5.0, jdk1.5.0_09 on Windows XP, SP2.
    Many thanks,
    Netbeans Fan.

    while (snomedCodes.iterator().hasNext())
      output.write( snomedCodes.toString() );
    }Here you have some kind of a list or something (I couldn't stand to read all that unformatted code but I suppose you can find out). It has an iterator which gives you the entries of the list one at a time. You keep asking if it has more entries -- which it does -- but you never get those entries by calling the next() method, so it always has all the entries still available.
    And your code inside the loop is independent of the iterator, so it's rather pointless to iterate over the entries and output exactly the same data for each entry. Even if you were iterating correctly.

  • Writing a file using ssh in OSB 11g

    Hi
    OSB 11G
    Once I fetch from DB, i am able to write a flat file(delimiter with pipe) using Messaging Service and MFL.
    Now, my requirement is to write using SSH .
    Can anyone let me know how do I configure it in my Business Service?
    Thanks
    Edited by: soauser on Jul 12, 2011 9:08 AM

    OSB supports SSH File Transfer Protocol (SFTP) using SSH version 2 with SFTP transport -
    section "26.5 SFTP Transport" at http://download.oracle.com/docs/cd/E17904_01/doc.1111/e15866/http_poller.htm#i1085854
    If existing options are not sufficient, you may also create custom transport using transport SDK and use that in OSB -
    http://download.oracle.com/docs/cd/E17904_01/doc.1111/e15866/part_tsdk.htm#sthref954
    Regards,
    Anuj

  • Writing multiple files using UTL_File package

    Hi,
    I have an requirement where I need to read the flat file and based on the first 3 character in each line which will be compared with the FlagTable, I have to create and move data into different files.
    I'm using Oracle 11g in Windows xp platform.
    Example:
    Content of the FlatFile:
    ND1T00XNDCNON0080
    [email protected]
    XR1 0000000179CONVERSION
    PT1006 ON00014
    XR195010120391231P0012 19950101 0000000179CONVERSION
    ND2995010120391231a000000000000000000
    XR2 0000000416PP C941995010120391231PP0012 19950101
    GP206 0120391231a000
    GP2061231a00000000000000 1231a0000000000000
    FlagTable:
    Id     Flagtype Flag
    1     ND1     Y
    2     ND2     Y
    3     GP2     
    4     XR1     Y
    5     XR2     
    6     PT1     
    Possible output should be (duplicate files should not be created)
    BP_ND1.txt
    ND1T00XNDCNON0080
    ND151995010120391231a0000000000000000000000000000XNDCNON0080
    BP_ND2.txt
    [email protected]
    ND2995010120391231a000000000000000000
    BP_XR1.txt
    XR1 0000000179CONVERSION
    XR195010120391231P0012 19950101 0000000179CONVERSION
    BP.txt
    PT1006 ON00014
    XR2 0000000416PP C941995010120391231PP0012 19950101
    GP206 0120391231a000
    GP2061231a00000000000000 1231a0000000000000
    Please let me know, if more info is required.
    Regards,
    Lokesh

    How your task is related to Oracle?
    This better be done with Perl or VB or whatever, but not with using RDBMS.

  • Writing XML files using file adapter

    Hi All,
    I am using Oracle file adapter to write xml files, I am poinitng it to an xsd while specifying schema.The XML files are getting generated with target namespace information and name space prefixes in the xml data elements. I have a specific requirement to create xml files without any namespace/name space prefix tags in it. Can we acheive it using file adapter?
    otherwise is there anyother way of doing this in bpel.
    Any suggestions are welcome.
    Thanks

    What is the name you have entered in sender channel, if you have entered.pdf only it process PDF files. select option skip empty file option in sender channel and enter name ..
    most probably this issue coming with empty files.

Maybe you are looking for

  • When did Apple start using LED backlights for display panels?

    I am a relative newcomer to Apple world. As an electronics professional, I am interested in display technology and progress. Apple displays have been impressive for some years,particularly the MacBooks etc. Does anyone know the historical points when

  • Created Webi report using BEx Query.

    Hi All, I am going to upgrade in BW and using BEx  & Webi Report. I have created webi report using BEx query. Now I need to test data in webi report. Can anyone tell me how to test data? Regards,

  • Adobe Captivate 6 problem with Review area text on Quiz results page

    Hi, I am using Adobe Captivate 6 and I have a test at the end of my project with the built in 'Quiz results page' at the end. However, the standard 'review area' provided always seems to play up for me. I have changed the 'quiz results messages' thro

  • Detecting a change in a system matrix - cnt'd

    Hello, This is from one of my previous questions: [quote] When an order or any other sales document is created, I want to detect if a change is made to the quantity, price, etc. of any of the lines of the document, and then change or add another line

  • HT1688 iPhone screen extremely sensitive to any touch

    In the last week I can barely get close to the screen while talking on the phone because if someart of my face touches the screen it will end the call,put the on hold, mute, whatever..... Help