Article View: borland.public.jbuilder.java.language
Article #17416Re: Problems writing newlines to a file
From: Graham Lovell
Date: Thu, 19 Nov 1998 00:00
Date: Thu, 19 Nov 1998 00:00
38 lines
1809 bytes
1809 bytes
Dear Matt,
I tried your code, so that we could learn how to write to a file, which I
hadn't been able to do so far, and it worked OK, including the new lines.
(Thanks for the help, albeit this was not your immediate objective.)
The new line came through OK as a newline, (extra newlines and text also
worked OK) when read in both WordPad and in the Browser (I didn't bother to
use an binary reader as it was working OK).
Could this be a browser problem? I have had very variable results from
different browsers. I used Internet Explorer 4.0 SP1, in testing this code.
Graham
Matt Butler wrote in message <72sc3h$14a13@forums.borland.com>...
>I am having an problem with writing new lines to a file. I have tried
>several different things, but to give you an idea here is the latest code I
>tried:
>
> String s = new String("test\n");
> char[] buf = new char[s.length()];
> s.getChars(0,s.length(),buf,0);
> Writer out = new OutputStreamWriter(new
>FileOutputStream("D:\\WWW\\Html\\User3.rpt"));
> out.write(buf,0,s.length());
> out.flush();
>
>What is happening is that the \n is coming out as an unprintable character
>rather than a newline. It works fine if sent to system.out rather than a
>file.
>
>Any ideas?
>
>Thanks,
> Matt
>
>
Technical Details
Message-ID:
<7311k7$qo74@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<72sc3h$14a13@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,1b6563995c977abb X-Google-Attributes: gidf74b3,public From: "Graham Lovell" <glovell@pennantsw.com.au> Subject: Re: Problems writing newlines to a file Date: 1998/11/19 Message-ID: <7311k7$qo74@forums.borland.com> X-Deja-AN: 413480656 References: <72sc3h$14a13@forums.borland.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: Pennant Software Pty Ltd Newsgroups: borland.public.jbuilder.java.language