How To Make Age Call In Java With Bufferedreader And Inputstreamreader

Aug 18, 2014

I am having problems in creating an age calculator in java. The only input is your name and date of birth. It means I need to incorporate the current date and make conditions. I am only allowed to use BufferedReader, InputStreamReader and IOException for import. I need to start with this and just add the conditions,

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
public class ageactivity
{
public static void main (String[] args) throws IOException
{
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

[code]...

I tried to add conditions but its not calculating the days.

View Replies


ADVERTISEMENT

Will SP Call From Java Make 2 Round-trips To DB?

Feb 5, 2014

We are in the process of developing a e-commerce application. It is a web site for a book shop. It is a site very similar to Amazon.com where you can order books online.  Front end is in Java Technology.  There is however a concern about where to put the business logic.
 
I am suggesting to put all business logic in the Oracle Database, as stored procedures (i.e. packages). However, one of my colleague says that when you call a Oracle stored procedure from Java, it takes 2 round trips, one to validate the procedure and then to validate the input / ouput parameters of the procedure.
 
In a website application like what we are trying to build, is it sound advice to put all business logic in the DB? Or should it be in the middle tier (app. server) programmed in Java? Or should you spread in between the middle tier and DB? If so how?

View Replies View Related

Difference Between InputStream And InputStreamReader

Jul 11, 2014

I read that InputStream is used for byte based reading it reads 1 byte at a time.And InputStreamReader is used for charcter based reading so it reads one charcter at a time so no need to convert this first to int then read it.Here is reading using InputStream.

input=new FileInputStream("D:/input.txt");
int c;
while((c=input.read())!=-1)
{
System.out.print((char)c);
}

and here is reading using InputStreamReader

input=new FileInputStream("D:/input.txt");
reader=new InputStreamReader(input,"UTF-8");
int c;

while((c=reader.read())!=-1)
{
System.out.print((char)c);
}

so what is difference between InputStream and InputStreamReader in both case i have to use a Int and then read it and at the end if I want to print that data I have to cast that with "(char)c".So what is advantage of using InputStreamReader?

View Replies View Related

InputStreamReader Looking For File Location

Apr 26, 2014

The file (let's call it file.txt) is on the C: of my machine. I'm using :

System.out.print("Where is the file?: "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

And looking for the user to enter the location of the file in the console. How do I (the user) enter the path to the file in the console. I have tried everything... "C:file.txt", C:file.txt, and a million other combinations. Nothing seems to work. How does the console expect the file path to be written so it knows how to pick up the file?

View Replies View Related

Bufferedreader Into Jtable

Dec 6, 2014

I have created Jtable which stores images and Strings, I can SAVE the content to external file, however whenever I will try to load it back (below code) to JTable, it throws me an error. One field in the JTable uses renderer for images, and the code throws everything back as a String ) how can I transform one 'word' (e.g. /usr/etc/test.jpg) in a text file to ImageIcon which will be handeled by the renderer? Should I read the file 'word' by 'word' store it as array and load it into column?

private void check() {
String path = "Tab.csv";
File source = new File(path);
if (source.exists()) {
DefaultTableModel mdl = (DefaultTableModel) Tab.getModel();
String line;
BufferedReader reader;

[code]....

View Replies View Related

Using BufferedReader To Put Strings In ArrayList

Sep 27, 2014

We haven't covered BufferedReader in this course yet. The assignmen is to get user input to fill arraylist with strings then when user hits Enter without any input, the console displays the contents of the arraylist.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Ex01 {
public static void main(String[] args) throws IOException {

[code]....

View Replies View Related

BufferedReader - Passing Parameters

Mar 7, 2015

Using Eclipse. I have this line of code:

BufferedReader br = new BufferedReader(new InputStreamReader(in));

I want to do something with br in a method that I defined. But Eclipse is complaining about br declared as

public static void Get_Next(String next_line, BufferedReader br) {

How do I make this work?

View Replies View Related

Compile Error In Line Bufferedreader

Sep 24, 2014

import java.util.*;
import java.lang.*;
class Bank {
String name;
float acc_no,balance;
void accept(String str, float no, float bal)

[code]....

View Replies View Related

Why Is BufferedReader Not Reading But Clearing Text File

Mar 30, 2014

Followed this: [URL]

public static final String FILENAME="BinarySearchTree.txt";
....
public BinarySearchTree(TNode r) throws IOException {
root = r;
textfile = new File(FILENAME);
fw = new FileWriter(textfile.getAbsoluteFile());
bw = new BufferedWriter(fw);
br = new BufferedReader(new FileReader(FILENAME));

[code].....

In the constructor I create the BufferedReader using the FileReader and path to the input text file(in same dir as this project). When I am done reading I close it. In the debugger it is unable to read a single line, then goes to close the file.

View Replies View Related

Reading In A File With BufferedReader / Using Tokenizer For Adding Into Adjacency Matrix

Mar 6, 2015

I am having trouble adding numbers read from a file with BufferedReader, using Tokenizer to split the numbers up by " " - space and adding them to an adjacency matrix.Below is the text file and my code, that I have at the moment.

0 1 0 0 1 1 0 0
1 0 0 0 0 1 1 0
0 0 0 1 0 0 1 0
0 0 1 0 0 0 0 1
1 0 0 0 0 1 0 0
1 1 0 0 1 0 0 0
0 1 1 0 0 0 0 1
0 0 0 1 0 0 1 0

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.StringTokenizer;
public class Foo
{
@SuppressWarnings("null")
public static void main(String[] args) throws Exception
{
String line, token = null, delimiter = " ";

[code]....

View Replies View Related

How To Call Java Methods From Different Java File

Apr 14, 2015

I create 2 files:

CircleCalculationMethod.javaMain.java 

In Main.java, How can i call method in CircleCalculationMethod.java ?

Should I put everything in same folder ??Should i do something like "import CircleCalculationMethod.java"Should i do something like create a package ...

I use Eclipse software

View Replies View Related

Call DTS From Java

Jul 21, 2014

whether we can call DTS directly from Java.Solution which we got as below:-

1. Create dts

2. Create job in which we have to call dts

3. Call job from stored procedure

It pretty lengthy process and we are not sure how error handling can be done in this scenario.

View Replies View Related

Call DTS From Java

Jul 22, 2014

We are using MS SQL server 2000, in which we have explored calling dtsrun.exe from Runtime class in java. But it is not suggested way to call dts, as error handling will be difficult.

whether we can call DTS directly from Java.

View Replies View Related

BufferedReader - Read Names Off Of Email Addresses In A Text File And Print To Console

Nov 5, 2014

I'm trying to write a program to read the names off of email addresses in a text file and my code is not printing anything to the console. So I want to print everything before the "@" sign. It seems like I'm missing a big thing
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class Email {
public static void main(String[] args) throws FileNotFoundException, IOException {
 
[Code] ....

View Replies View Related

To Call Java Method In JSP

Apr 28, 2014

I am trying to call a java method in jsp. The main idea is to hide menu based on the user who logs in. The java class flows like this :

public class UserVerification {
public static void main(String[] args) {
UserVerification obj = new UserVerification();
System.out.print(obj.GetUserVerification("abc"));

[Code] ......

View Replies View Related

Not Able To Call Java Method From Event

Mar 4, 2014

I used java and jsf. I created dynamic datatable in java file. Can i call java method from setOnchange() event?

I am able to call java script function from setOnchange() event. See the below code which is working fine for java script.

HtmlSelectOneMenu selectOneMenu = new HtmlSelectOneMenu();
selectOneMenu.setStyleClass("dropdownStyleTwo");
selectOneMenu.setOnchange("openWin(this);IGNORE_UN LOAD=false");

I wrote openwin() function in java script. But i am not able to call java method change().

Code which is not working.

HtmlSelectOneMenu selectOneMenu = new HtmlSelectOneMenu();
selectOneMenu.setStyleClass("dropdownStyleTwo");
selectOneMenu.setOnchange("myclass.change();IGNORE _UNLOAD=false");

myclass is the bean of class Test. If user select any value from dropdown i want to call change java method. This function will apply the same selected dropdown value to the other record also.

View Replies View Related

How To Call Abstract Method In Java

Feb 18, 2014

I am new to Java and have been learning it. I have a question here. I came across the following Java class and trying to understand it thoroughly but got confused how it is able to call an abstract method. Here is the code I am referring to :
 
package sampleapps.gui;
import javax.swing.*;
import java.awt.*;
 public class InnerClassAnimationExample {
    int x=70, y=70;
    public static void main(String[] args) {
 
[Code] ....
 
So, in the code above, there is an inner class NewMyDrawPanel which has a paintComponent(Graphics g) method. I have highlighted 2 lines of code above.
 
Line 1 : Graphics2D g2d = (Graphics2D) g;
Line 2 : g2d.fillOval(x,y,40,40);

I understand we are type casting reference g to Graphics2D reference g2d and we are calling fillOval() method on g2d. I don't see a fillOval() method in Graphics2D class but it is there in Graphics class and fillOval method is an abstract method.
 
So, my question here is :
 
1. If we are not able to instantiate an abstract class(Graphics2D and Graphics classes), how are we able to access the fillOval() abstract method,

2. Secondly, since the fillOval() method is an abstract method, it does not have any implementation for the method.

However, when I call the method fillOval() on Graphics2D reference, I was able to draw and fill an oval of the specified co-ordinates. So, where would the actual implementation code be?

View Replies View Related

How To Call EAR File From Standalone Java Code

Apr 14, 2014

I have a EAR file which has a java class file and EAR file is deployed in weblogic.I have to call the java class of EAR file from a standalone java code which is present inside a JAR.While making the call to EAR i have to pass a parameter from JAR to one of the methods of class file which is present in EAR.

View Replies View Related

Call A Java Method Using Only Varags In Its Prototype

Jun 12, 2014

I have to call a java method using only varags in its prototype :

public void _instanceMethod(Object... obj) {
....
}

that is equivalent to :

public void _instanceMethod(Object obj1, Object obj1, ..., Object objn) {
....
}

My question is simple : I only own a List<Object>How can I set each element of _instanceMethod parameter from my List ?? If i decided to iterate through my list such as :

for (Object obj : myList){
_instanceMethod(obj);
}

How can I correctly "populate" the _instanceMethod varargs signaturee by the n elements of my list ?

View Replies View Related

Java Swing Frame Can't Call On Other Methods From Main

Mar 25, 2015

I am trying to make a 2d graphical animation using the java swing classes in order to make a frame. I had a basic version working when all of the code was under the main method, but when I moved some into another method it broke it. With y understanding of java my code should work as I create a variable of the method containing the code and then assign the size and exit button. However this causes many problems such as my BeaconFrame method informing me that it is unused when I have used it. Here is my code:

import javax.swing.*;
import java.awt.*;
 public class BelishaBeacon {
  public void BeaconFrame() {
JFrame frame = new JFrame();
JPanel panel1 = new JPanel();

[code]....

View Replies View Related

Call SQL Server Stored Procedure Using JDBC In Java

Mar 23, 2015

I'm new to Java. I need to run a SQL server stored procedure(that creates a unique job number) from Oracle SQL Developer (JDBC) in Java. The same Java code will be used in Applescript to run the SP. I found a code snippet online with the similar requirement. How to embed my SP in below code snippet?  Below is the Stored Procedure and Code Snippet:
 
SP
 
EXEC Int.dbo.GetNewJobNumber '6852', 'Test Job', 'Manual SQL Query'
6852- CustomerCode,
Test Job - Job Title,
Manual SQL query - Shows how new job number was created.
 
Code Snippet:

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
 
public class Main {
  public static void main(String[] argv) throws Exception {
 
[Code] ....

View Replies View Related

Java Game - Breaking Down A Method To Smaller Methods And Where To Call

Aug 6, 2014

I have a question about a method I have. In my game, I had a move method to move my player left and right, and originally this method was huge, as it also took care checking collisions and a few other things. I broke it up a bit and put the collisions in their own methods and call them from again another method... Here is an extract which I hope illustrates my point:

private static final double MOVE_SPEED = 0.2;
private static final double MAX_MOVE_SPEED = 3.5;
private static final double STOP_SPEED = 0.18;
private double xPos;
private double yPos;

[Code] .....

Something I thought might be a good idea is to check the direction collision when im doing the calculations for that direction:

if(moveLeft) {
dx -= MOVE_SPEED;
(dx < -MAX_MOVE_SPEED) {
dx = -MAX_MOVE_SPEED;
}
checkLeft();
}

But then I would also need to check it when I'm slowing down the left movement:

if(dx < 0.0) {
dx += STOP_SPEED;
if(dx > 0.0) {
dx = 0.0;
}
checkLeft();
}

Then I thought instead i can check it after both of these steps:

if(moveLeft || dx < 0.0) {
checkLeft();
}

I guess my question is quite general: How much is acceptable to break up a method? How many chains of method calls is acceptable? Is it ok to call the same method from different nearby places?

View Replies View Related

How To Call Java Class File From Press Of Button On Apex

Dec 23, 2013

I am newbie in java and little bit known to apex. I  write an java code and compile it to class file. Now i want to call that class file from an push of button on apex. When button is pushed i need some arguments to be password to java class files . For arguments i need to take the item value from the apex page.
 
But i stuck on how to call that java class file from apex. On command prompt when i ran java class file, its working.

View Replies View Related

Make A Calculator Using Java GUI

Jul 29, 2014

I am trying to make a calculator using Java GUI. I've managed to make an ActionListener and add it to a button, but I've made an error in my code that I'm unsure of how to solve. Because of how I've written the code, only one number can be placed in the text field. For example, the an ActionListener for the three button on the calculator was added to the button, but no matter how many times the user presses the button, only one 3 will appear in the text field. The code is below:

import javax.swing.*;//import the packages needed for gui
import java.awt.*;
import java.awt.event.*;
public class Calculator {
public static void main(String[] args) {
JFrame window = new JFrame("Window");//makes a JFrame
window.setSize(300,350);

[code].....

As you can see, because the compiler forces the String variable to be final, so when the user presses the button, the code simply shows how a space character and three character would look like, because the String variable can't change. How do I write my code so that every time the user presses the button, a character is added to the text field?

View Replies View Related

Make A Database Using HTML And Java

Oct 17, 2014

I would like to make a database using HTML and Java. I already made something like this using swing. I am just looking for some pointers here. I just started looking into Java Play 2 and I have a feeling this is what I am looking for. JavaEE is very complicated and I have read that it is being phased out. What is your opinion on this?

I want to make a static HTML page and put it on my home network and treat one of my computers as the sever accessing mySQL.

View Replies View Related

How To Make COMPLETELY UNIQUE Java GUI

Apr 6, 2014

I want a completely unique GUI with unique buttons, like I could make it a giraffe if I wanted to! (not going to, but a giraffe seemed like a pretty irregular shape) ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved