27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Operational Systems & <strong>Java</strong><br />

page, his system locked up and he had to reboot. After the reboot he said his registry<br />

was corrupted and had to be restored.<br />

Has anyone seen anything like this? if so, do you have any suggestions as to<br />

probable cause and fix?<br />

Answer: Any time you don't shutdown properly, your registry can be corrupted, even<br />

if the program that did the freezing was not even using the registry.<br />

The registry is one of the stupidest ideas ever conceived in computer science. It puts<br />

ALL your eggs in one basket.<br />

by Roedy Green<br />

For the JAVA GLOSSARY see http://mindprod.com/jgloss.html<br />

Q: Does anybody know how to find out the complete path of a system default<br />

browser (if there's such) from a <strong>Java</strong> stand alone app?<br />

Answer: Under Windows you can 'invoke' the default browser calling<br />

'start filename.html', under Unix is a lot more complicated because nobody can<br />

assure you that a browser exists and the user is under X....<br />

--<br />

Davide<br />

Q: ...The problem is that, after the file is uploaded to the server, every end of line<br />

is placed with ^M character...<br />

I have written a servlet which uploads a file from client(Win32) to server (Unix). I<br />

have used DataInputStream to read the file in bytes and FileOutputStream to write<br />

the file to the location in the server.<br />

The problem is that, after the file is uploaded to the server, every end of line is placed<br />

with ^M character. This problem is faced only when I upload to Unix <strong>Server</strong> from<br />

Windows O/S.<br />

Answer: This is normal, I think. A line ends with a single return symbol in Unix and<br />

ends with a return symbol and a switching line symbol in Windows. The editor in Unix<br />

shows "^M" when it meets the switching line symbol.<br />

So to fix this bug, you can remove the switching line symbol in the end of lines when<br />

you upload files from Windows to Unix.<br />

Or Use a BufferedReader to read the source file (line by line) and a BufferedWriter to<br />

write the destination file. That way the source line separators will be discarded and<br />

the correct separators (according to the target OS) will be used.<br />

If you only have an InputStream to start with, use InputStreamReader to convert it to<br />

a reader.<br />

--<br />

Jorge<br />

Q: I have a server written in <strong>Java</strong> that I would like to start up as a NT<br />

service...does anyone know how to do this?<br />

Answer: Check this site:<br />

http://www.kcmultimedia.com/smaster/<br />

I read there:<br />

"ServiceInstaller is a FREE utility that makes it easy to install programs as Windows<br />

file:///F|/350_t/350_tips/os_win_linux.htm (6 of 8) [2002-02-27 21:18:56]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!