Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

file read behave differently in Window / Unix

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends..

I am stuck in tricky situation and would appreciate if someone can give me some direction on following issue,

Working environment is -
JDK 6, Websphere 8

My EAR has an EJB, that EJB reads file content from remote system and provide the data as byte [ ]


In my local, using Websphere @ Windows platform, returned byte [ ] is different from Websphere on AIX platform

for new line on Windows I am getting - 13, 10
and on AIX I get - 10


ASCII Character Codes
10 \n (NL)
13 \r (CR)



in local (Windows) env. I can get file and that remains well formatted... but file downloaded using same EAR in dev (on AIX) file content keep continue to same line.

if I open same file with Notepad++, textpad or any other editor format of that file remains good.. but since Notepad is default editor I need to address the issue...

please let me know if you can give me some clue / direction...

regards..




 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's normal. Different operating systems use different characters for end-of-line.

Windows uses CR LF (ASCII codes 13 and 10). Most Unix-like operating systems such as AIX use only LF (ASCII code 10).

Is this causing a problem in your application?
 
Bartender
Posts: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

San Metro wrote:but since Notepad is default editor I need to address the issue...


In which case, why not change your default editor?

The fact is that this is a Windows problem, not a Java or other OS one, because it's the only major OS that continues to use that ridiculous line terminator (which is actually a holdover from the days of line printers).

If you use methods like BufferedReader.readLine() in your Java programs, they will work correctly for any OS; and pretty much any utility you use in Linux, Unix or Apple OS/X will deal with Windows text files perfectly happily.

HIH

Winston
 
Sheriff
Posts: 14759
245
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is on a tangent but why do you need an EJB to do that? Seems like a sledgehammer to hang up a small picture frame.
 
Marshal
Posts: 67527
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Winston Gutkowski wrote: . . . a holdover from the days of line printers). . . .

I remember those infernal machines well. No, it was a TTY (=Teletype), which was even worse. The only good thing about it was the you had to push the key marked “Campbell Ritchie” to terminate a line. You then had to push the key marked LF to move onto the next line. At least if you wanted to read the printout you did
 
San Metro
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all for quick replies...

why we are using EJB - sorry it might look like excuse.....
this solution is implemented in approx. 2002 or bit later and currently using Java 5 / Websphere 6 which works good... (provide same output on Win/AIX),
I am participating to upgrade the Java 6 / Websphere 8;

I am trying to debug more on how EJB is getting the stream (byte [ ])..

thank you & regards..
 
Winston Gutkowski
Bartender
Posts: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:No, it was a TTY (=Teletype), which was even worse.


You're probably right. In Solaris (don't know about Linux), terminal devices are still called /dev/tty...

Computer History 101.

Winston
 
Rancher
Posts: 1041
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:
(don't know about Linux), terminal devices are still called /dev/tty...



They abound:
[obu@obutest ~]$ uname -a
Linux obutest 2.6.18-371.8.1.el5 #1 SMP Fri Mar 28 05:53:58 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

[obu@obutest ~]$ ls /dev/tty[0-9]*
/dev/tty0 /dev/tty12 /dev/tty16 /dev/tty2 /dev/tty23 /dev/tty27 /dev/tty30 /dev/tty34 /dev/tty38 /dev/tty41 /dev/tty45 /dev/tty49 /dev/tty52 /dev/tty56 /dev/tty6 /dev/tty63
/dev/tty1 /dev/tty13 /dev/tty17 /dev/tty20 /dev/tty24 /dev/tty28 /dev/tty31 /dev/tty35 /dev/tty39 /dev/tty42 /dev/tty46 /dev/tty5 /dev/tty53 /dev/tty57 /dev/tty60 /dev/tty7
/dev/tty10 /dev/tty14 /dev/tty18 /dev/tty21 /dev/tty25 /dev/tty29 /dev/tty32 /dev/tty36 /dev/tty4 /dev/tty43 /dev/tty47 /dev/tty50 /dev/tty54 /dev/tty58 /dev/tty61 /dev/tty8
/dev/tty11 /dev/tty15 /dev/tty19 /dev/tty22 /dev/tty26 /dev/tty3 /dev/tty33 /dev/tty37 /dev/tty40 /dev/tty44 /dev/tty48 /dev/tty51 /dev/tty55 /dev/tty59 /dev/tty62 /dev/tty9


 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!