windows - Java reading from binary file -


i have calculated data (floats , integers), written 12mb file this

dataoutputstream os3; os3 = new dataoutputstream(new fileoutputstream(cache.class.getresource("/3w.dat").getpath())); ...... (some loops)      os3.writefloat(f);      os3.writeint(r); os3.close(); 

and after read way

datainputstream is3; is3 = new datainputstream(new fileinputstream(cache.class.getresource("/3w.dat").getpath())); ...... (same loops)      is3.readfloat();      is3.readint(); is3.close(); 

so, wrote file once on windows 7. after read while app starts. file reading works fine on windows 7, when try on ubuntu, eof exception (code , file same).

i suspect problem may caused nan values written file.

btw. while debugging figured out on ubuntu reading process runs 15% of loop , throws exception. values reads "0.0", file doesnt contain zeros.

the problem should different of line break between linux , windows. mentioned clark, replace \n \r\n , end of line character resolve this. can use notpad++ simplify work. click on menu :

edit -> eol conversion -> convert unix format

it might problem of encoding. if you'are using windows, default encoding windows-1252 or called cp-1252, specially microsoft thing , cannot recognized on linux. change encoding utf-8 can recognized os. using notpad++:

encoding -> convert utf-8


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -