CAt utility in java


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers CAt utility in java
# 1  
Old 02-09-2009
CAt utility in java

Hello friends,

could you please advice me of how to traslate this program written in C to java?

#include <cstdio>
main( ){
char c;
c = getchar( );
while (c != EOF) {
putchar(c);
c = getchar( );
}
}

I am supposed to test the difference in time between compiling the C program and the corresponding java program in unix. I would appreciate the help or clues to figure it out. thank you very much for your time
# 2  
Old 02-09-2009
There's an easier way to get fixed-width chars in this forum, and it preserves spacing too, try code tags, [ code ] stuff [ /code ] without the extra spaces in the tags.

You might find this useful. Instead of opening files you could just use System.in and System.out
# 3  
Old 02-11-2009
Just add a point here that if performance is important to you, you may find the NIO API of more interest compared with the conventional Java IO API.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Programming

Java Cat and Mouse Game

I am having problems with another exercise from a website to learn Java. I am supposed to create classes for a game called cat and mouse. Basically, there is a grid 5x5 (representing the island) surrounded by water and has 6 bridges off the grid. The cat is hungry and wants the mouse, but the... (4 Replies)
Discussion started by: totoro125
4 Replies

2. Shell Programming and Scripting

Cannot open txt file in UNIX using cat utility

Hi, I am not being able to open txt files with 'cat'. One thing to mention is, the filenames start with #. I guess one can have a unix filename that starts with a special/wildcard character. I have filenames starting with @ and they are opening perfectly with cat. (5 Replies)
Discussion started by: Subhasis
5 Replies

3. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

4. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

5. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies
Login or Register to Ask a Question