![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
|
Reading Files in Java problem
I am new to the Java language::: Any hard core java coders out there!
I need a Simple JAVA snippet that will take a reference file a, that has the following information : 0|TicketType 1|Version 2|TimeStamp 3|TimeZone of TimeStamp 4|Assignment1 5|Assignment2 6|Logical1 7|CorrelationType 8|CorrelationID 9|TicketSequenceID 10|DisconnectBFlag It should then pick a file b that is delimited with the | character, and print out the various fields as per reference file a. 1|34|2008.01.07 12:21:55|12|4|5-1-1254710754638|abc401|0|00000101A20200000008F8164781EF260C00|0|0|E00318FFFFBFFFFE|254710754638|16| So that the output is 0|TicketType = 1 1|Version = 34 2|TimeStamp = 2008.01.07 12:21:55 3|TimeZone of TimeStamp = 12 4|Assignment1 = 4 5|Assignment2 = 5-1-1254710754638 6|Logical1 = abc401 7|CorrelationType = 0 8|CorrelationID = 00000101A20200000008F8164781EF260C00 9|TicketSequenceID = 0 10|DisconnectBFlag = 0 many thanks |
|
|
|
|
|
#2 |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 920
Rep Power: 4
![]() |
Re: Reading Files in Java problem
What's that smell? I think I stepped in something. Smells like either dog shit, or homework. <sniff> Yup, definitely homework. Clean your own shoes off; don't ask us to do it for you.
Translation: Show you've first made an attempt on your own, or you're not likely to receive any help here.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
Re: Reading Files in Java problem
I agree with lectricpharaoh... at least show us you tried to resolve the problem yourself first.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#4 |
|
Newbie
|
Re: Reading Files in Java problem
this is what i have managed to pull.
import java.io.*; class FileRead { public static void main(String args[]) { try{ // Open the file that is the first command line parameter FileInputStream fstream = new FileInputStream("a.txt"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println (strLine); } //Close the input stream in.close(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } } } class FileWrite { public static void main(String args[]) { try{ // Create file FileWriter fstream = new FileWriter("write_me.txt"); BufferedWriter out = new BufferedWriter(fstream); out.write("create new file and write into it!!/n"); //Close the output stream out.close(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } } } |
|
|
|
|
|
#5 |
|
11 years old
Join Date: Nov 2007
Posts: 79
Rep Power: 1
![]() |
Re: Reading Files in Java problem
java Syntax (Toggle Plain Text)
Study the code a lot, and then rebuild it your own way, and then use that.
__________________
iload_0 iconst_1 ishl or iload_0 iconst_2 idiv or iload_0 iconst_2 iconst_1 imul idiv [1] & [2] use the smallest stack size |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help. I got a problem in making Java games .. | bratsercom | Java | 11 | Oct 1st, 2007 2:31 PM |
| reading in a file in java | ryanl | Java | 3 | Sep 8th, 2005 9:54 AM |
| Java script problem | zeotrex | JavaScript and Client-Side Browser Scripting | 5 | Sep 2nd, 2005 5:30 AM |
| Reading Files, and Formating | brokenhope | C++ | 6 | Apr 18th, 2005 4:01 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |