Making an ASCII file into a text file

Hi-
I am trying to read the lines of an ASCII file as Strings and write them to a new text file. Eventually I will modify the info in the lines, but for now I'm just trying to get the flow from one file to another. I can't figure out how to write a String to a new file. Below is the code that I've written so far, followed by the error that i get when I run it (it compiles fine). One problem I see is that FileWriters are made to write characters, but I want to write Strings to a new file. How do I get around this?
import java.io.*;
import java.lang.*;
import java.util.*;
class Delimiter {
public static void main (String[] args) throws IOException {
try {
File inputFile=new File("test.asc");
File outputFile=new File(test.txt");
BufferedReader in=new BufferedReader(new FileReader(inputFile));
BufferedWriter out=new BufferedWriter(new FileWriter(outputFile));
String line=" ";
while (line != null) {
line=in.readLine();
out.write(line);
out.newLine();
in.close();
out.close();
} catch (IOException e) {
ERROR:
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Unknown Source)
at Delimiter.main(Delimiter.java:23)

sorry, I responded too quickly. I put out.write(null);
just before the in.close(); statement and got an error
saying that command is ambiguous b/c write() could
belong to multiple classes. did you mean that I should
put it in the while loop?I didn't mean for you to put
out.write(null);
in your code. I meant to point out that when 'line' is null, the problem is that you are passing a null to the out.write() method. That is bad. Don't do that. Use the above. It will test for null before doing the write().

Similar Messages

  • Write Query Results into a text file

    Hello All,
    In SAP B1 Query Generator I'm trying to write the results of a query into a text file (.txt). I've tryed with queryout but it doesn't work.
    What I want is something like this:
    SELECT * FROM TABLE queryout "C:/textfile.txt"
    Any sugestions?
    Thanks in advance,
    Miguel Barbosa

    Hello All,
    Since yesterday and due to your help, I've found how to solve my problem.
    This post is only to share with you and with the others users of Expert Forums how to Write the results of an SQL Query in SAP Business One to a Text File without making it by exportation.
    Requested Text File by customer:
    Document type in R/3 If Invoice -- 'Z100' - Position 1 to 4 - 4 characters
    Supplier Code -- dbo.Table.CardCode -- Position 5 to 15 - 10 characters
    Item Code -- dbo.Table.ItemCode -- Position 11 to 25 - 14 characters
    Client Code -- dbo.Table.CardCode -- Position 26 to 36 - 10 characters
    Client Name -- dbo.Table.CardName -- Posiiton 37 to 100 - 63 characters
    Fixed Blank Field -- ' ' -- Position 101 to 120 - 19 blank spaces
    Quantity -- dbo.Table.Quantity -- Position 121 to 140 -- 19 characters
    Unit Price -- dbo.Table.PriceBefDi -- Position 141 to 160 -- 19 characters
    If Invoice Fixed identifier -- 'Z01' -- Position 161 to 163 -- 3 characters
    Fixed Blank Field -- ' ' -- Position 164 to 220 -- 56 characters
    Document Date -- dbo.Table.DocDate -- Position 221 to 229 - 8 characters
    Delivery Date -- dbo.Table.ActDelDate -- Position 230 to 238 - 8 characters
    Sales Order Number - dbo.Table.DocNum -- Position 239 to 260 - 21 characters
    Delivery Number - dbo.Table.DocNum -- Position 261 to 282 - 21 characters
    Follows the code:
    EXEC master..xp_cmdshell'bcp
    SELECT DISTINCT
    ''Z100''
    + ''ZP00002091''
    + IsNull(Convert(nVarChar(44), Cast(T0.DocNum As Numeric(38, 0))), '''')
    + ''PTAP''
    + ''          ''
    + ((LTRIM(RTRIM(T1.U_NumConc)))) + SPACE(10-LEN(LTRIM(RTRIM(T1.U_NumConc)))) + ((LTRIM(RTRIM(T3.BaseRef)))) + SPACE(10-LEN(LTRIM(RTRIM(T3.BaseRef))))
    + ''                    ''
    + ''Z02''
    + CONVERT(varchar(10), T1.ActDelDate, 112)
    + CONVERT(varchar(10), T0.DocDate, 112)
    + ''    ''
    + IsNull(Convert(nVarChar(44), Cast(T1.BaseRef As Numeric(38, 0))), '''')
    + ((LTRIM(RTRIM(T1.ItemCode)))) + SPACE(18-LEN(LTRIM(RTRIM(T1.ItemCode))))
    + ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.Quantity AS NUMERIC (38,3))))),'' '',''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,3),T1.Quantity))))),''.'','''')
    + ''0'' + REPLACE(SPACE(12-LEN(CONVERT(varchar(12), CAST(T1.PriceBefDi AS NUMERIC (38,2))))),'' '', ''0'') + REPLACE(((LTRIM(RTRIM(CONVERT(NUMERIC(38,2),T1.PriceBefDi))))) ,''.'','''')
    + ''ZPHA''
    + ''          ''
    + ''  ''
    + ''                         ''
    + ((LTRIM(RTRIM(T4.CardName)))) + SPACE(69-LEN(LTRIM(RTRIM(T4.CardName))))
    + ''                        ''
    + CONVERT(varchar(10), T0.DocDate, 112)
    + ''               ''
    FROM
    JFOTST.dbo.OINV T0
    INNER JOIN JFOTST.dbo.INV1 T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN JFOTST.dbo.ODLN T2 ON T2.DocNum=T1.BaseRef
    INNER JOIN JFOTST.dbo.DLN1 T3 ON T3.DocEntry=T2.DocEntry
    INNER JOIN JFOTST.dbo.OCRD T4 ON T1.U_NumConc=T4.AddId
    WHERE T0.CardCode=''C52''
    queryout "c:\text1.txt" -c -T -x'
    Note that in this code everytime you need to use the symbol ' you have to doble it like ''Fixed Text''.
    Be aware that there is one UDF so if you try to make this query run in your SB1 you will have to create a UDF called U_NumConc in the document lines.
    Database usage:
    JFOTST.dbo.OINV T0
    JFOTST.dbo - Database Name.
    OINV - Table
    T0  - Alias
    For any doubts I'll be available to help.
    Once again thank you very much for all your help.
    Together we are stronger!
    Kind Regards,
    Miguel Barbosa
    Edited by: Miguel Barbosa on Aug 18, 2009 12:09 PM
    Edited by: Miguel Barbosa on Aug 18, 2009 12:10 PM

  • Issue while uploading .TIFF file into Standard text using RSTXLDMC

    Hi All,
    We are facing issues while uploading .TIFF file into standard text through program RSTXLDMC.
    Getting the following error.
    TIFF format error: No baseline TIFF 6.0 file.
    The image is a colored one.
    Please provide me solution if anyone has worked in this area.
    Thanks in Advance,
    Anand Raj Kuruba.

    Hi,
    Often this error occurs because the TIFF file you have has been saved with some form of compression.  You need to open in a picture edit program and save as TIFF making sure options are set so there is no compression.
    Andrew

  • Export all logs into ascii files

    Hi,
    is there a way to automatically export all logs created with SignalExpress (I use the 2009 edition) automatically to ascii files, taking the names of each log as a base for the file name?
    I am aware of the export to LVM/Ascii possibility, but this requires to manually edit the file name for each file.
    So what I am looking for would be a way to apply the Options->Logging->"Automatically export log to text file" _afterwards_. Is there a way?
    Cheers,
    Niels

    Hi Nils,
    There is currently no utility or simple mechanism built into SignalExpress that will take an already created log, and then export it to ASCII.
    I can think of a way to do it, as a "workaround" to say the least (assuming Time Waveform or Scalar logs).
    1. Create a new SignalExpress project.
    2. Import the logs you want to export to ASCII.
    3. Go to Tools >> Options... and in the Logging section, set Automatically export log to text file = Yes.
    4. Switch to Playback mode and select the first log.
    5. Drop a Formula step and leave the default values (with Formula Y=x0)
    6. Rename the output of the formula step as desired.
    7. Right-click on the output of the formula step and select "Enable Recording".
    8. Run the project.
    From this point out, running the project will create a new (duplicate) log, and inside the new log folder will also be the exported ASCII file. By changing the active log, you can export each log.
    Note 1: I did try using the Batch Process Log feature to export all logs at once, but SignalExpress returned an error after the first log...
    Note 2: I'm not sure the names will be generated exactly as you would have liked.
    I completely realize this is NOT ideal!
    Phil

  • Open and read from text file into a text box for Windows Store

    I wish to open and read from a text file into a text box in C# for the Windows Store using VS Express 2012 for Windows 8.
    Can anyone point me to sample code and tutorials specifically for Windows Store using C#.
    Is it possible to add a Text file in Windows Store. This option only seems to be available in Visual C#.
    Thanks
    Wendel

    This is a simple sample for Read/Load Text file from IsolateStorage and Read file from InstalledLocation (this folder only can be read)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Windows.Storage;
    using System.IO;
    namespace TextFileDemo
    public class TextFileHelper
    async public static Task<bool> SaveTextFileToIsolateStorageAsync(string filename, string data)
    byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(data);
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    var file = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
    try
    using (var s = await file.OpenStreamForWriteAsync())
    s.Write(fileBytes, 0, fileBytes.Length);
    return true;
    catch
    return false;
    async public static Task<string> LoadTextFileFormIsolateStorageAsync(string filename)
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    async public static Task<string> LoadTextFileFormInstalledLocationAsync(string filename)
    StorageFolder local = Windows.ApplicationModel.Package.Current.InstalledLocation;
    string returnvalue = string.Empty;
    try
    var file = await local.OpenStreamForReadAsync(filename);
    using (StreamReader streamReader = new StreamReader(file))
    returnvalue = streamReader.ReadToEnd();
    catch (Exception ex)
    // do somthing when exception
    return returnvalue;
    show how to use it as below
    async private void Button_Click(object sender, RoutedEventArgs e)
    string txt =await TextFileHelper.LoadTextFileFormInstalledLocationAsync("TextFile1.txt");
    Debug.WriteLine(txt);
    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

  • How can I convert an audio file (speech) into a text?

    Hello everybody!
      Can someone explain how I can convert a garageband file (voice speech) into a text? My Mac is a Mac OS X 10.5.8 version, so I don't have programs such as mountain Lion. I thought to use googlevoice. Is this option available? If yes, how can I use it?
    Thanks.

    Hello, I only find google voice available for Abdroid!?
    http://www.ehow.com/info_10033225_google-voice-system-requirements-android.html
    Some possibilitities, not sure if they have 10.5.8 compatble versions anymore...
    http://atmac.org/speech-to-text-dictation-software-for-os-x
    Some reviews of later Dragon Speak...
    http://www.finetunedmac.com/forums/ubbthreads.php?ubb=showflat&Number=22962

  • How to store the data coming from network analyser into a text or excel file

    Hii everyone
    I'm using Agilent 8719ET network analyser and wish to store the data coming from netowrk analyser into a text file/ excel file.
    Presently I'm able to get the data on Labview graph using GPIB . Can anyone suggest how to go ahead after collect data sub vi. How can the data be stored into a file apart from showing on the graph?
    Attached is the vi for kind consideration...
    Looking for help
    Regards
    Rohit
    Attachments:
    Agilent 87XX Series Exceed Max Meas.vi ‏43 KB

    First let me say that your code really looks pretty good. The data handling could be made more efficient by calculating the number of datapoints that are going to be in the completed dataset and preallocating the entire array -- but depending upon your answer to my questions, the logic in the lower shift register may be going away - so we won't worry about that right now.
    The thing I need to know before addressing the data storage question is: Each time you call "Collect and Display Data.vi", how many element are in the array? Are you reading single data points, or a group of data? (BTW: if the answer to that question is obvious based on the way the other VIs are setup, I don't have the drivers so I can't tell what the setup values are.) Second, how fast does the loop iterate? Are we talking msec per loop?, seconds? fortnights?
    The issues here are two-fold: how much data? and how fast is it coming? The answer to these will tell you how to save the data.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Download Internal Table into a Text File in BSP?

    I have an internal table which i need to download into my local pc. I know i can not use FM gui_download. Could some one please post code on how to download the internal table into a text file in BSP. Also i am not sure if i can use save dialog FM. Also need suggestion on which FM to use for save dialog which tells where to save the file.
    Any help will be appreciated.
    Thanks
    Nahman

    This might be a good starting point.
    <a href="/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table">/people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table</a>

  • Write arrays into a text file in different columns at different times

    Hi,
              I have a problem write data into a text file. I want to write 4 1D arrays into a text file. The problem is that I need to write it at different time and in different column (in other word, not only append the arrays).
    Do you have an idea to solve my problem?
    Thank you

    A file is long a linear string of data (text). In order ro insert columns, you need to rewrite the entire file, because colums are interlaced over the entire lenght of the file.
    So:
    read file into 2D array
    insert columns using array operations
    write resulting 2D array to file again.
    (Only if your colums are guaranteed to be fixed width AND you know the final number of colums, you could write the missing columns as spaces and then overwrite later. Still, it will be painful and inefficient, because column data are not adjacent in the file.)
    LabVIEW Champion . Do more with less code and in less time .

  • ORA-06521: PL/SQL: Error mapping function while writting into a text file

    Hi,
    I'm getting an errror ORA-06521: PL/SQL: Error mapping function while trying to write data into a text file.
    I'm using the following code:
    --To create a new directory
    create or replace directory temp as 'C:/temp';
    declare
                    l_str varchar2(1000);
                    output_file utl_file.file_type;
                    cursor test_write_cur is
                         select EMPNO,ENAME,JOB,SAL,HIREDATE
                           from EMP
                         where DEPTNO=30;
    begin
               output_file := utl_file.fopen('TEMP','TESTFILE.txt','w');
               for test_write_rec IN test_write_cur
               loop          
                l_str :=     test_write_rec.EMPNO||'^'||test_write_rec.ENAME||'^'||test_write_rec.JOB||'^'||
                         test_write_rec.HIREDATE||'^'||test_write_rec.SAL||chr(10);
                utl_file.put_line(output_file,l_str);
                     end loop;                                                                           
               utl_file.fclose(output_file);
    end;Please suggest me if i'm wrong.
    Thanks & Regards,
    Sanket Mishra

    Dear Sanket,
    I think you are need use TO_CHAR() function
      to_char(test_write_rec.EMPNO) ,
      to_char(test_write_rec.HIREDATE,'DD.MM.YYYY')
      to_char(test_write_rec.SAL)

  • Letter-Spacing is different if I open my file at another Mac of us (Value is at both mac 0, but the text is longor), and if I cklick into the text-box, Illustrator says that the file was made in an other Version of Illustrator. We have on all macs the sam

    Letter-Spacing is different if I open my file at another Mac of us (Value is at both mac 0, but the text is longor), and if I cklick into the text-box, Illustrator says that the file was made in an other Version of Illustrator. We have on all macs the same system, os 10.8.3, cs6 and UTC4. And of course we`re using exactly the same font....

    Packpool,
    I believe the first thing to do is to update to 16.0.5.
    Adobe - Illustrator : For Macintosh

  • How to output a query results into a text file

    How to output a query results into a text file instead of outputing it to the screen..
    is there a way for us to write a SQL query which specifies to output the query results to a text file.
    Pls let me know how to do it
    Thanking u in advance
    regards
    Muraly

    Muraly,
    If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
    SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
    SPOOL c:\temp\report.html
    SELECT DEPARTMENT_NAME, CITY
    FROM EMP_DETAILS_VIEW
    WHERE SALARY>12000;
    SPOOL OFF
    SET MARKUP HTML ENTMAP OFF
    In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
    Alison

  • How to convert a HTML files into a text file using Java

    Hi guys...!
    I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
    By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
    Thank you....

    HTML files are already text files. What do you mean you want to convert them?
    I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean).

  • Mapping and loading  single ASCII file into multiple tables in ODI

    We get an ASCII file that contains several different transactions (records) and I need to validate and map each record to different table in the target database using Oracle Data Integrator tool. Is it possible ? If so, how and how difficult it is ?
    I would appreciate a quick response.
    Thanks,
    Ram

    Hi Madha,
    Using Demo version, we are trying to load data from ASCII file. When trying to execute, we are getting the following error:
    7000 : null : com.sunopsis.jdbc.driver.file.a.icom.sunopsis.jdbc.driver.file.a.i
    at com.sunopsis.jdbc.driver.file.a.f.getColumnClassName(f,java)
    at com.sunopsis.sql.e.a(e.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(SnpSessTaskSql.java)
    The file has all text fields and no date fields. we made sure that there is data for all fields being loaded.
    Question is whether there is any problem in creating data in the Demo database which cameup with installation?
    I mean, do we need to create any privileges to insert/add/delete ? We are running this as user SUPVERVISOR .
    I appreciate if you can respond to this.
    thanks,
    Ram

  • How to extract the Html content of a UI Map into a text file or html file?

    Hi,
    Is there any possibility in OUAF or Java or from the Database, to retrieve the Html Content of a given a UI Map ?
    If UI Map name is the input, then it should fetch the entire html portion of it into a text file. How to acheive this?
    This needs to be done programatically either by writing some Java code or some SQL at the DB level?
    Edited by: OATS Explorer on Dec 29, 2012 9:10 AM

    F1_MAP.HTML_DEFN would give the html contents and F1_SCHEMA.SCHEMA_DEFN would give you the UI Map's Schema.
    SELECT map.map_cd
      , map.html_defn
      , sch.schema_defn
    FROM f1_map map
      , f1_schema sch
    WHERE map.map_cd = sch.schema_name
    AND sch.schema_type_flg = 'F1MP'

Maybe you are looking for

  • Using Time Machine to backup a iMac G5 and restore to an intel iMac

    Is it possible to use Time Machine to backup my iMac G5 and restore my backup to a new intel iMac? The reason being is that I my mother-in-law's company bought her a new intel Mac and she wants to trade with me since she only uses her Mac for e-mail,

  • Authorization check for Easy Document Management

    Hello, I'm using ECC6 without cProjects or any other implementations regarding the authorization concept in Easy DMS. I'm trying to use authorization control inside the Easy DMS GUI but these settings won't work. I need document based authorization a

  • Slideshow Music and iTunes on Mac?

    How do I get a Playlist that I have in iTunes on my Mac to be selectable in the LR Slideshow Module?  I have an iTunes Playlist on my Mac that I want to use as music on a LR Slideshow.  How do I do that?  I have the latest Lightroom and the Latest OS

  • Why is this page displaying like this?

    I'm trying to convert this page so that the layout is based on server-side include files but since doing this the page is displaying incorrectly. What have i done wrong? http://www.milesfunerals.com/donations_2.php

  • Hidde database values when looping through jsp:useBean collection

    <jsp:useBean id="categories" scope="request" class="java.util.Collection"/> <c:forEach var="dto" items="${categories}">                <td width="375px" class="categoryContentTD">${dto.categoryName}</td> <td width="75px" class="categoryContentTD">${d