Adding extra control charcters in a ZIP file.

I am creating a GZip file in linux by a java program. After Unzipped(by using gunzip command) the file in linux i am getting the file with the correct data. I ftped the file from Linux to Unix in binary mode. After unzipped(by using gunzip command) the file in Unix i am not getting the file with correct data. The control character(^M) is adding at every end of line. I am not able to find why its happening. Anyone can help me ?

Plz..........

Thanks

[470 byte] By [Rosy_Thomas@Javaa] at [2007-11-27 7:07:52]
# 1
"line"? in a GZIP?
CeciNEstPasUnProgrammeura at 2007-7-12 18:59:19 > top of Java-index,Java Essentials,Java Programming...
# 2
You need to make sure you FTP the file in BINARY mode and not ASCII mode. Many FTP clients default to ASCII mode and convert end-of-line characters.
sabre150a at 2007-7-12 18:59:19 > top of Java-index,Java Essentials,Java Programming...
# 3
After zipped the file, the new line symbol is adding at the end of line.
Rosy_Thomas@Javaa at 2007-7-12 18:59:19 > top of Java-index,Java Essentials,Java Programming...
# 4
Hi I ftped the file in binary mode only. still its displaying.
Rosy_Thomas@Javaa at 2007-7-12 18:59:19 > top of Java-index,Java Essentials,Java Programming...
# 5
> Hi > I ftped the file in binary mode only. still its> displaying.Sorry, I misread your post. The ^M chars are caused by your editor trying to display \r\n . Check out the dos2unix command e.g. man dos2unix .
sabre150a at 2007-7-12 18:59:19 > top of Java-index,Java Essentials,Java Programming...
# 6

I implemented the dos2unix command in java.

The implementation of this command is,

public void dos2Unix(String dosFileName){

File dosFile = new File(dosFileName);

File tempFile = new File(dosFile.getAbsolutePath() + ".tmp");

try

{

BufferedReader in = new BufferedReader(new FileReader(dosFile));

BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));

int c;

while((c = in.read()) != -1)

{

if(c != '\r')

out.write(c);

}

in.close();

out.close();

dosFile.delete();

tempFile.renameTo(dosFile);

}

catch(IOException e)

{

throw new RuntimeException(e.getClass() + e.getMessage());

}

}

Now its working fine

Thanks a lot

Rosy_Thomas@Javaa at 2007-7-12 18:59:19 > top of Java-index,Java Essentials,Java Programming...