Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing an output of a java application to a File.  RSS feed

 
shivarama krishna
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I want to the output of the below applcations to a text file.

import java.util.Scanner;
import java.io.*;

public class Linga {

int startNode,sum=0;
Scanner ss = new Scanner(System.in);
/**
* @return
*/
public int readValue(){
System.out.println("Enter your startNode number------");
startNode = ss.nextInt();
return startNode;
}
public int resultValue(){
int c;
startNode = readValue();
int endNode=0;
System.out.println("Enter your endNode number------");
endNode = ss.nextInt();
System.out.println("n value is "+startNode);
if(endNode>0)
for(c=startNode;c<=endNode;c+=20)
{
System.out.println("Inside of result calculating******"+c);
sum = sum+c;
}
return sum;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println();
Linga ll = new Linga();
System.out.println("ll.resultValue()>>>>>>>>>>>>"+ll.resultValue());
}
}



thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java Linga > output.txt

works on Unix-ish OSes as well as Windows.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!