Steven Smith

Greenhorn
+ Follow
since Dec 12, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Steven Smith

Thank you all for your help! Just wondering though if there are any methods that will automatically read/write the '\r', '\n', '\t', etc. The problem is, I can't visibly see these in the input file. I only know they are there because the output file formatting is all "out of whack".
[ September 28, 2006: Message edited by: Steven Smith ]
18 years ago
I'm trying to read a file with formatted text (tabbing etc.), then writing it to a new file. However, the formatting is getting lost to the new file. What should I do?
What I tried:
FileWriter out = new FileWriter(outfile);
BufferedReader br = new BufferedReader(new FileReader(infile));
String tmpstr = "";
while((tmpstr = br.readLine()) != null) {
out.write(tmpstr);
}
18 years ago

Originally posted by Jim Yingst:
I think we need more info to make sense of what you're doing here...



Yes, sorry my fault. I was trying to be brief and not get detailed, but it made more confusion. Anyway, I got it working now by simply reading the file in a while loop and totaling the bytes. Thanks
[ August 21, 2006: Message edited by: Steven Smith ]
18 years ago

Originally posted by Steven Smith:

Without getting into details, need the length in bytes.



May have worded this wrong. Need length using a stream.
18 years ago

Originally posted by Paul Clapham:
The length of what?

If you need to know the number of bytes in the file, then the very first reply in this thread tells you how to find the number of the bytes in a file. Did you just overlook that, or do you have a question about it?



Using a stream, not simply File.length().
18 years ago

Originally posted by Jim Yingst:

Actually I would probably prefer to rewrite the subsequent code so that there is no need to have all the content in a single byte[] at one time. E.g. using streams.



Thanks Jim, using streams is actually what I'd like to do, since file may be huge. Without getting into details, need the length in bytes. Any hints to get started?
18 years ago
length() returns long.
[ August 21, 2006: Message edited by: Steven Smith ]
18 years ago
What's the best way to get the byte lenght of a FileInputStream? I read in the bytes to an array list then get the size of the array list. I'm wondering if there is a better way?
18 years ago
If not, what's a good way to do it? C program is already created, but I need it to be able to talk to Java.
18 years ago
Is it possible to create a dll in Java so a C/C++ program can access a Java class? If so, can you recommend some resources/web links?
18 years ago
Using a very simple example:
Want to get this "#abc#def#ghi#jkl" from this "abcdefghijkl"
This will work:
String str = "abcdefghijkl";
String tmpStr = "";
String newStr = "";
for (int i = 0; i < str.length(); i = i+3){
tmpStr = str.substring(i, i + 3);
newStr = newStr + "#" + tmpStr;
}

Is 'newStr = newStr + "#" + tmpStr;' efficient?
What's a better way if str is huge?
18 years ago

Originally posted by Junilu Lacar:

Like Jeff said, adding two times doesn't mean a whole lot of sense.



Sorry, I just realized I shouldn't have wrote "time stamp." I think what I'm asking is much simpler. If driving my car from point A to point B takes 5 hours and 10 seconds (05:00:10) and driving from point B to point C takes 1 hour, 35 minutes and 5 seconds (01:35:05), I want to add the two times together (point A to C = 06:35:15) with everything in hh:mm:ss format. Also, if it took 25 hours to go from point A to point B, I would end up with 26:35:05, not a clock time. The two times would be string values already provided (in hh:mm:ss) but I need to add them together.
[ December 13, 2005: Message edited by: Steven Smith ]
18 years ago
Strings representing time stamps.
18 years ago
How do I add 2 time stamps in hh:mm:ss format?
For example: 05:00:10 + 01:35:05
[ December 13, 2005: Message edited by: Steven Smith ]
18 years ago