473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Eclipe Console

281 100+
Good Day!
I have one large real application (numerical) and build and run it using eclipse.
Eclipse console gives VERY long list of output and I can see only half of them.
How to get the whole (complete) output viewed in console?
Maybe I need to export all the result in text or whatever?
Please help me. TIA
Mar 14 '07 #1
5 1648
r035198x
13,262 8TB
Good Day!
I have one large real application (numerical) and build and run it using eclipse.
Eclipse console gives VERY long list of output and I can see only half of them.
How to get the whole (complete) output viewed in console?
Maybe I need to export all the result in text or whatever?
Please help me. TIA
Using the console for out put is not the correct thing to do for large applications. You should use a text file instead. Write a static utility method called say.
Expand|Select|Wrap|Line Numbers
  1. public static printToFile(String s)
, and use that to log all events. In that method you simply open a file for appending and append the String s to that file. You then replace your System,out.println statements with the ClassName.printToFile method.
Mar 15 '07 #2
shana07
281 100+
Using the console for out put is not the correct thing to do for large applications. You should use a text file instead. Write a static utility method called say.
Expand|Select|Wrap|Line Numbers
  1. public static printToFile(String s)
, and use that to log all events. In that method you simply open a file for appending and append the String s to that file. You then replace your System,out.println statements with the ClassName.printToFile method.
Could you please check my code: what's wrong with it....
In my text file, only last line was printed.
Expand|Select|Wrap|Line Numbers
  1.  public static void printToFile(String s) 
  2.   {
  3.       try
  4.         {
  5.         FileOutputStream fout;        
  6.         fout = new FileOutputStream ("output.txt");    
  7.             new PrintStream(fout).println (s);   
  8.         fout.close();
  9.         }
  10.         catch (IOException exc)
  11.         {
  12.             System.out.println("CAN'T OPEN THIS FILE !!!");
  13.         }     
  14.  
  15.   }
Mar 16 '07 #3
Could you please check my code: what's wrong with it....
In my text file, only last line was printed.
Expand|Select|Wrap|Line Numbers
  1.  public static void printToFile(String s) 
  2.   {
  3.       try
  4.         {
  5.         FileOutputStream fout;        
  6.         fout = new FileOutputStream ("output.txt");    
  7.             new PrintStream(fout).println (s);   
  8.         fout.close();
  9.         }
  10.         catch (IOException exc)
  11.         {
  12.             System.out.println("CAN'T OPEN THIS FILE !!!");
  13.         }     
  14.  
  15.   }
It's in the constructor of your FileOutputStream. It comes, by default overloaded, ie many ways to call the constructor by varying the parameter-list passed to the same constructor name.

The one you are using overrides everything in a file it is writing to each time u call it. Use the one with two arguemnts, the string file_name and the boolean append_option set to true. This will allow u to have th whole output in tha file.

Try this

try
Expand|Select|Wrap|Line Numbers
  1.  public static void printToFile(String s) 
  2.   {
  3.       try
  4.         {
  5.         FileOutputStream fout;        
  6. // N00199B added here
  7.         fout = new FileOutputStream ("output.txt",true);    
  8.             new PrintStream(fout).println (s);   
  9.         fout.close();
  10.         }
  11.         catch (IOException exc)
  12.         {
  13.             System.out.println("CAN'T OPEN THIS FILE !!!");
  14.         }     
  15.  
  16.   }
[/quote]
Mar 16 '07 #4
r035198x
13,262 8TB
Could you please check my code: what's wrong with it....
In my text file, only last line was printed.
Expand|Select|Wrap|Line Numbers
  1.  public static void printToFile(String s) 
  2. {
  3. try
  4. {
  5. FileOutputStream fout;        
  6.      fout = new FileOutputStream ("output.txt"); 
  7. new PrintStream(fout).println (s); 
  8.      fout.close();
  9. }
  10. catch (IOException exc)
  11. {
  12. System.out.println("CAN'T OPEN THIS FILE !!!");
  13.  
  14. }
Do not use streams for writing to a file! Use BufferedWriter and FileWriter.
The reason you get one line printed is probably because you are opening the file in overrride mode. Open it in append mode using FileWriter as follows

Expand|Select|Wrap|Line Numbers
  1.  FileWriter fos = new FileWriter("foo.txt", true); 
Then wrap the fos variable in a BufferedWriter and write to it.
Mar 16 '07 #5
dav3
94
Expand|Select|Wrap|Line Numbers
  1.  FileWriter fos = new FileWriter("foo.txt", true); 

Had this issue in a recent project:)
Mar 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
7
by: shawnk | last post by:
Hello Everyone How do you format format numbers right-justified using Console.WriteLine(), i.e I need to line up numbers in vertical columns and the MSDN documentation is pretty poor Here is the...
5
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough...
5
by: Publicjoe | last post by:
I am working on a little app which uses colour in the console window. I have created a class to extend the console functionality but the ClearScreen method does not work correctly. I am enclosing a...
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
5
by: portroe | last post by:
Hi I am using console.Writeline in my simple program. I do not however see anything happening in the output window when I debug, there are also no error messages, Has anybody a tip on what...
6
by: tony | last post by:
Hello! When you have windows forms you have the same possibility as when you have a Console application to use Console.Writeln to write whatever on the screen. Now to my question: Is it...
1
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.