How to use Character.toUpperCase(c) method in below program?
Dear,
I have a source code as below. I want to ask how to convert all lower case letters in input file(farrago.txt) to upper case letters in the output file(outagain.txt)? Where the method Character.toUpperCase(c) adds into the code?
Please help!
import java.io.*;
public class Copy {
public static void main(String[] args) throws IOException {
File inputFile = new File("farrago.txt");
File outputFile = new File("outagain.txt");
FileReader in = new FileReader(inputFile);
FileWriter out = new FileWriter(outputFile);
int c;
while ((c = in.read()) != -1)
out.write(c);
in.close();
out.close();
}
Sorry, i did not see that c is an int, so do it like this
while ((c = in.read()) != -1)
char C = Character.toUpperCase((char)c);
out.write(C);
}Noah
Similar Messages
-
How to use two split this method in my code
How to use two split this method in my code
if i got one string line which like this
("aa!bb!cc~ab!bc!cd") a
nd want to use two split to spare ! and ~ this seal for my spare point how that output
has come diff ?
public static void main(String[] args) {
String str = "aa!bb!cc~ab!bc!cd";
String strs[]= str.split("~");
String strE[]= str.split("!");
int count =0;
for(int j=0; j < strs.length; j++){
for (int i = 0; i < strE.length; i++){
System.out.println(count + " " + strE);
count++;
the output how can it be like this
0 aa
0 bb
0 cc
1 ab
1 bc
1 cdMove your second slit inside the first loop, so you are splitting the substring, not the entire string.
-
This is my Name class:
class Name {
private String title;
private String name;
public Name(){
title=" ";
name=" ";
public Name(String title){
setTitle(title);
name=" ";
public Name(String title,String name){
setTitle(title);
setName(name);
public void setTitle(String title){
this.title=title;
public String getTitle(){
return title;
public void setName(String name){
this.name=name;
public String getName(){
return name;
} This is my Person Class
class Person extends Name{
private String address;
private String tel;
private String email;
public Person(){
super();
address=" ";
tel=" ";
email=" ";
public Person(String name){
super(name);
address=" ";
tel=" ";
email=" ";
public Person(String title,String name,String addressStr){
super(title,name);
setAddress(addressStr);
tel=" ";
email=" ";
public Person(String title,String name,String addressStr,String phoneNum){
super(title,name);
setAddress(addressStr);
setTel(phoneNum);
email=" ";
public Person(String title,String name,String addressStr,String phoneNum,String emailStr){
super(title,name);
setAddress(addressStr);
setTel(phoneNum);
setEmail(emailStr);
public void setAddress(String add){
address=add;
public String getAddress(){
return address;
public void setTel(String telephone){
tel=telephone;
public String getTel(){
return tel;
public void setEmail(String emailAdd){
email=emailAdd;
public String getEmail(){
return email;
public boolean equals(Person inputRecords){
boolean equalOrNot=false;
if(inputRecords.super(getTitle()).equals(title)) //this is wrong
if(inputRecords.super(getName()).equals(name)) //this is wrong
if(inputRecords.getAddress().equals(address))
if(inputRecords.getTel().equals(tel))
if(inputRecords.getEmail().equals(email))
equalOrNot=true;
return equalOrNot;
public void makeCopy(Person copyInto){
copyInto.super(setTitle(title)); //this is wrong
copyInto.super(setName(name)); //this is wrong
copyInto.setAddress(address);
copyInto.setTel(tel);
copyInto.setEmail(email);
}How can I correct the wrong part?
I don't understand how to use super in equals() method and makeCopy() method.Try something like this ...
public boolean equals(Object other) {
if (other==null || !(other instanceof Person)) return false;
Person that = (Person) other;
return getTitle().equals(that.getTitle())
&& getName().equals(that.getName())
&& getAddress().equals(that.getAddress())
&& getTel().equals(that.getTel())
&& getEmail().equals(that.getEmail())
Notes:
* This overrides Object's public boolean equals(Object other), which is (probably) what you meant.
* You don't need to call "super.getWhatever" explicitly... just call "getWhatever" and let java workout where it's defined... this is better because if you then override getTitle() for example you don't need to change your equals method (which you would otherwise probably forget to do, which would probably have some interesting side effects.
Cheers. Keith. -
How to call a standard BOR method in a program.
Hi All,
How to call a standard BOR method in a program. For example I have to call BOR method ISUSMORDER.Release in my program but don't know how to call.
Also, plz tell me how to capture the Exceptions in case of BOR method.
Plz help me out in this.
Thanks,
MithileshWould be easier (however not always possible), to determine the functionality of this method and call that in your program. I mean, normally this method calls a BAPI, or function module (or a transaction). Have a look at the coding inside of the method, and try and use this.
-
How to use dynamic selection screen inputs in main program
hi all,
its a report where in it calls one dynamic selection screen( user need to enter the parameters here) after that i need to use those inputs for some check, can any buddy help how to use/ get that input parameters into main program.
regards,
vara..Hi,
i think u have created that dynamic selection screen in seperate program and calling to ur main program.instead of that u just create that synamic selection screen program as include program and include it in ur main program.
or u need to use set/get parameter id concept.
rgds,
bharat. -
How to use outer join condition in my below query.
Hi All,
How to use outer join condition in my below query.
In the table APPS_JP.GEDIS_OFFER_HEADER goh I have more records
in the table APPS_JP.GEDIS_ORDER_BUILDS gob I have less number of records.
I want all the records from APPS_JP.GEDIS_OFFER_HEADER goh
including other conditions.
I have tried goh.OFFER_NO=gob.OFFER_NO(+) but same result.
[code]SELECT GOH.ORIG_SYSTEM,
gsp.USER_NAME,
goh.ORDER_NO,
goh.OMEGA_ORDER_NUMBER,
goh.ORDER_TYPE,
gc.CUSTOMER_ID,
gc.OMEGA_CUSTOMER_NUMBER,
CASE WHEN gc.PRIVATE = 'N' THEN gc.CUSTOMER_NAME ELSE '' END
AS COMPANY_NAME,
goh.ORDER_STATUS,
goh.TOTAL_SELLING_PRICE,
goh.TOTAL_MARGIN,
ga1.ADDRESS1
|| ','
|| ga1.ADDRESS2
|| ','
|| ga1.ADDRESS3
|| ','
|| ga1.POSTAL_CODE
|| ','
|| ga1.CITY
AS SHIPPING_ADDRESS,
ga2.ADDRESS1
|| ','
|| ga2.ADDRESS2
|| ','
|| ga2.ADDRESS3
|| ','
|| ga2.POSTAL_CODE
|| ','
|| ga2.CITY
AS BILLING_ADDRESS,
ga.ADDRESS_ID,
gol.DESCRIPTION,
APPS_JP.TZ.to_local_date (goh.OFFER_DATE, goh.OFFER_DATE_UTC)
AS OFFER_DATE,
gc.LEVEL_8,
goh.NO_OF_BUILDS,
gob.SFDC_ID,
goh.PURCHASE_ORDER_NO AS PO,
gc1.CUSTOMER_NAME AS END_USAGE,
gol.LOB,
goh.TOTAL_MARGIN_PCT,
goh.TOTAL_DISCOUNT,
goh.TOTAL_DISCOUNT_PCT
FROM APPS_JP.GEDIS_OFFER_HEADER goh,
APPS_JP.GEDIS_ORDER_BUILDS gob,
APPS_JP.GEDIS_ORDER_LINES gol,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER gorc,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER ship,
APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER bill,
APPS_JP.GEDIS_CUSTOMER gc,
APPS_JP.GEDIS_CUSTOMER gc1,
APPS_JP.GEDIS_CONTACT gct,
APPS_JP.GEDIS_ADDRESS ga,
APPS_JP.GEDIS_ADDRESS_NORM ga1,
APPS_JP.GEDIS_ADDRESS_NORM ga2,
(SELECT DISTINCT SALESPERSON_ID, USER_NAME
FROM APPS_JP.GEDIS_SALESPERSON
WHERE SALESPERSON_ID IN
(SELECT TO_NUMBER (COLUMN_VALUE) AS SALESPERSON_ID
FROM TABLE (APPS_GLOBAL.SplitString ('337309'))))
gsp
WHERE goh.ORDER_NO <> 0
AND goh.OFFER_NO <> 0
AND goh.OFFER_NO=gol.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
AND goh.OFFER_NO=gob.OFFER_NO
AND gob.BUILD_NO = 1
AND goh.OFFER_NO = gorc.OFFER_NO
AND gct.CONTACT_ID = gorc.CONTACT_ID
AND ga.CUSTOMER_ID = gc.CUSTOMER_ID
AND ga.PRIMARY = 'Y'
AND goh.LEAD_SALESPERSON=gsp.SALESPERSON_ID
AND goh.OFFER_NO = ship.OFFER_NO
AND ship.RELATION_TYPE = 'SHIP'
AND ga1.ADDRESS_ID = ship.ADDRESS_ID
AND ga1.CUSTOMER_ID = gc1.CUSTOMER_ID
AND goh.OFFER_NO = bill.OFFER_NO
AND bill.RELATION_TYPE = 'BILL'
AND ga2.ADDRESS_ID = bill.ADDRESS_ID
AND goh.OFFER_DATE BETWEEN APPS_JP.TZ.LOCAL_TO_DB_DATE (
SYSDATE - 30
AND APPS_JP.TZ.LOCAL_TO_DB_DATE (SYSDATE)
AND gorc.RELATION_TYPE = 'BASE'
AND gorc.CUSTOMER_ID = gc.CUSTOMER_ID
AND goh.SALES_CHANNEL = gc.SALES_CHANNEL
AND gc.SALES_CHANNEL = 'SMB'
AND goh.LEAD_SALESPERSON IN (goh.CREATED_BY, goh.LEAD_SALESPERSON)
ORDER BY goh.OFFER_NO;[/code]
Please help me how to use this outer join condition.
Thanks in advance.Hi,
If you want all the rows from goh, then you don't want any conditions like goh.OFFER_NO <> 0.
Make all the joins to goh outer joins, and make all conditions that apply to any tables joined to goh (or to tables joined to them) part of the join condition, like this:
FROM APPS_JP.GEDIS_OFFER_HEADER goh
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_BUILDS gob ON gob.OFFER_NO = goh.OFFER_NO
AND gob.BUILD_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_ORDER_LINES gol ON gol.OFFER_NO = goh.OFFER_NO
AND gol.BUILD_NO = 1
AND gol.LINE_NO = 1
LEFT OUTER JOIN APPS_JP.GEDIS_OFFER_RELATED_CUSTOMER
gorc ...
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Simplify the problem as much as possible. For example, do you really need all those tables to show what the problem is? Of course, you need them in tyour real query, but if you understand a solution that only involves 4 or 5 tables, you'll know how to apply it to any number of tables.
Explain, using specific examples, how you get those results from that data.Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ https://forums.oracle.com/message/9362002#9362002 -
How to use JFrame's setLayeredPane() method?
I want to custom JFrame's LayeredPane by setLayeredPane() method,but it does't work.
Anyone who can help me?
The code as follows:
import javax.swing.*;
import java.awt.*;
public class LayeredTest{
public static void main(String[] args){
SwingUtilities.invokeLater(new Runnable(){
public void run(){
new MyFrame().setVisible(true);
class MyFrame extends JFrame{
public MyFrame(){
super("LayeredTest");
setLayeredPane(new JLayeredPane()); //this line, I want to set the LayeredPane myself;
//but it doesn't work.
JPanel panel =new JPanel();
panel.setPreferredSize(new Dimension(320,240));
panel.add(new JLabel("Label"));
panel.add(new JButton("Button"));
add(panel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
}Thanks!
But the very thing I want to know is "How to set Layered Pane(by setLayeredPane() method)",
not "How to use Layered Pane". -
How to use results of ejbfind methods when it is a collection ?
How to use ejbFind methods result , when it is a collection ?
Hi thank you for reading my post.
EJB find methods return a collection , i want to know how i can use that collection ?
should i use Collection.toArray() and then use that array by casting it?
what is DTOs and ho i can use them in this case?
How i can use the returned collection is a swing application as it is a colection of ejbs ?
Should i Cast it back to ejb class which it comes from or some other way ?
for example converting it to an array of DTO (in session bean) and return it to swing application ?
or there are some other ways ?
Thank youHi
pleas , some one answer
Collection collection = <home-interface>.<finderMethod>;
Iterator iter = collection.iterator();
while (iter.hasNext()) {
<remote-interface> entityEJB = (<remote-interface>) iter.next();
} what if i do the above job in session bean and convert the result to a DTO and pass the dto back ?
thank you -
Urgent!!! How to use IN_PARAMETER in CONSTRUCT_BSP_URL method
Hi sdn,
Iam new to bsp.I created a application with 2 controllers and 2 views.i want to transfer the values from one controller to another controller by using the runtime->construct_bsp_url().
in that one parameter " in_parameter" is used to pass the values from another controller.but i don't know how to use that parameter.please give me sample example or give me syntax for that parameter.
thank you for advance.
Award the useful answer.
thanks,
RamkumarhI,
method DO_HANDLE_EVENT.
DATA: event1 TYPE REF TO CL_HTMLB_EVENT.
DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
DATA: V_TARGET_URL TYPE STRING,
W_APP_NAME TYPE STRING.
event1 = CL_HTMLB_MANAGER=>get_event( runtime->server->request ).
if event1->name = 'button' and event1->event_type = 'click'.
data:button_event type ref to cl_htmlb_event_button.
button_event ?= event1.
if button_event->server_event = 'submit'.
data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
name = 'inputField'
id = 'ip1'
IF data IS NOT INITIAL.
input1 = data->value.
ENDIF.
data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
name = 'inputField'
id = 'ip2'
IF data IS NOT INITIAL.
input2 = data->value.
ENDIF.
DATA: lt_params TYPE tihttpnvp.
FIELD-SYMBOLS: GOTO_PAGE( V_TARGET_URL ).
endif.
endif.
endmethod.
THE ABOVE CODE I WROTE IN DO_HANDLER_EVENT() METHOD.I ACTIVATED AND TESTED.IN THE FIRST VIEW ASKING THE APPLICATION NAME AND CONTROLLER I GAVETHAT INPUTFIELDS BUT THE NEXT VIEW IN THE OTHER CONTROLLER NOT DISPLAYING.IT GEETING THE ERROR
BSP Exception: Das Objekt default.htm in der URL /sap/bc/bsp/sap/zehro_gr_fw_1/default.htm?input1=ZWFA_ESS04&input2=ZWFA_ESS04_01%2eDO&sap-sessioncmd=open ist nicht gültig.
Please resolve my issue. -
How to use $controller.DateTimeUtils.DateGet method ?
Hi everyone,
Can someone tell me how to use the $controller.DateTimeUtils.DateGet method ? I would like to know whether a date is a saturday or sunday but I can't figure out how to use the method.
Thanks in advance
ChrisSee the JMX documentation.
http://java.sun.com/javase/6/docs/api/javax/management/modelmbean/ModelMBeanInfo.html -
How to use FileOutputStream in a method??
Dear friend,
Now I want to write a program use java swing. I can get text from JPasswordField but I can't write the password in a document. I try to use FileOutputStream in a method with actionPerformed. But it seem no work. The problem is where should I put the 'throws IOException'? At the main or at the method?? Thank you very much.
Ah Siew.Hi!
You can write this methode in a
try
}catch(IOException)
or you write an throws IOException after the Methode.
Thats the Problem with to IOException
Now your other problem:
first: an JPasswordField is an javax.swing element.
You can get the String with the
String1 = PasswordFieldObject.getText(); Methode.
and than you can save it in an "Global" Var.
Greetings
F@b -
How to use '*' character in element names ?
Hi,
I have to use '*' character in element names. But, it throws DOMException. is there a workaround to use such illegal characters ?
thanks in advance...No, there is no work around as such. The '*' character is not a legal character in a tag name (it means zero or more in DTD content specifications).
http://www.w3.org/TR/2004/REC-xml-20040204/#NT-Name
What does the star mean? Replace it with something more meaningful. The closest thing to a work around is using "-star-", but then you have to replace dash with "-dash-" and it all gets a bit silly, and won't really add meaning to the tagname.
Pete -
How to use Java.lang.Math to calculate; Advice programming
Hi, all!
I am trying to teach myself Java, and am using the MindQ CDs to do it. I'm dreadfully stuck on this one exercise, and I could use some help figuring out how to properly call a Math method, store the variables, and print the results. I've programmed other methods successfully before; for some reason I just can't figure this one out. I've tried about fifty different configurations; maybe I can get some good advice here? Thanks!
import java.io.*;
import java.util.Random;
import java.lang.Math;
public class JavaCalcs {
public static void main(String args[]) {
System.out.println("Starting JavaComputations...");
//main method variable declarations
int z, y, x, w;
int A = -12;
int B = 2;
z = A & B;
y = A | B;
x = A >> B;
w = A >>> B;
System.out.println(z + ";" + y + ";" + x + ";" + w + ";");
Random kickassRNG = new Random();
double rDOne = kickassRNG.nextDouble() * 90.0;
double rDTwo = kickassRNG.nextDouble() * 90.0;
System.out.println("rDOne= " + rDOne);
System.out.println("rDTwo= " + rDTwo);
//NOTE-EVERYTHING WORKS FINE UNTIL THIS POINT...
if (rDOne > rDTwo)
System.out.println("The larger of the 2 degs. is rDOne");
//compute ceiling.
double a=rDOne; //Store the value of rDOne.
public static double ceil(double a);
return a;
System.out.println( "the ceiling of rDOne is " + a );
//convert degree measurement to radians.
public static double toRadians(double b);
double b = a;
System.out.println("rDOne in radians is " + b );
//compute tangent of that result.
public static double tan(double c);
double c = b;
System.out.println("The tangent of rDOne is " + c );
else
System.out.println("The larger of the 2 degs. is rDTwo");
//compute ceiling.
double a=rDTwo; //Store the value of rDOne.
public static double ceil(double a);
return a;
System.out.println( "the ceiling of rDTwo is " + a );
//convert degree measurement to radians.
public static double toRadians(double b);
double b = a;
System.out.println("rDTwo in radians is " + b );
//compute tangent of that result.
public static double tan(double c);
double c = b;
System.out.println("The tangent of rDTwo is " + c );
} //end main method.
}VERY useful link..thxYou're welcome. Here are some more:
Sun's basic Java tutorial
Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's Thinking in Java (Available online.)
Joshua Bloch's Effective Java
Bert Bates and Kathy Sierra's Head First Java.
James Gosling's The Java Programming Language. Gosling is
the creator of Java. It doesn't get much more authoratative than this. -
How to use the created search helps in the program?
Hi Everyone,
I know how to create Search help elementary / collective search help through SE 11. I have a question, how can I make use of the created search help in the program.
How to use the Search help in the programs, which is created through SE11
Subbu.Hi,
In case if you want to use in parameters statement, then we can use the suffix MATCHCODE OBJECT syntax.
Eg.
report abc.
parameters : a(10) type c matchcode object ZBELNR.
Hope this helps.
regards,
amit m. -
Plase can anybody tell me how to use SETS (GS01/02/03) in ABAP program
Plase can anybody tell me how to use SETS (GS01/02/03) in ABAP program
http://wiki.sdn.sap.com/wiki/display/Snippets/Reading+Sets+-+GS01+-+GS02+-+GS03
Maybe you are looking for
-
How to load and define Java Store Procedures using Consolidator Manager??
Hi, I am trying to create a store procedure with a very easy example and I can not succeed. i am a bit new with OLite and I will appreciate any help from your side. I am quite lost now regarding of using java with OLite and it is becoming quite urgen
-
Why did my Macbook Pro got so slow after formatting and reinstalling Mavericks?
I had Mavericks a month ago, then i upgraded to Yosemite, and my computer got extremely slow, so i formatted it and reinstalled Mavericks again, i feel it's slower than the last time i used it with Mavericks, i have no idea why. i erased my hard driv
-
Hello: OS 10.7.5. Safari 6.1.4. I close safari. I open it later. All the old tabs present in the previous session (I exited Safari), show up again. I tried the suggestion from Chris on unchecking an activity (I did this in safari 5; then, downloaded
-
I may have 4 different Firefox pages open with several tab on each....I got a new computer and now when I shut down at night it doesnt save my tabs.....so I can continue where I left off the day before?
-
Enhancement of transaction FV75
Hi Experts, I am working on Credit Note approval through Z-work flow to meet certain requirements which cannot be done in standard work flow. We have developed entire work flow in Z. The design is like this, Credit Memo will be parked in Transaction