Jump to content

Java Experts Chinna Help


Recommended Posts

Posted

check pm sent code

Posted

emi errors

 

 

comment //com.gen.csv

remove package and run from command prompt

 

Posted

thanks

ade comment chesa

 

indi inka vndi: the public type BenerateCSVFile must be defined in its own file

 

also command prompt nunchi ela run cheyali

Posted

Try this

 

class GetInputFromUser
{
public static void main(String args[])
{
int a;
int b;
String s1,s2;
 
Scanner in = new Scanner(System.in);
 
System.out.println("Enter an Number");
a = in.nextInt();
 

System.out.println("Enter a Range");
b = in.nextInt();
 
System.out.println("Enter a Name");
s1 = in.nextLine();
 
System.out.println("Enter a Alias");
s2 = in.nextLine();
 

System.out.println(a + "," + b + "," + s1 + "," + s2 );

}
}

 

 

btw idi net nundi ettinde

 

http://www.programmingsimplified.com/java/source-code/java-program-take-input-from-user

 

command prompt lo work autundi ..

 

system.out badulu file loki write cheste sariptundi

Posted

emi errors

 

 

comment //com.gen.csv

remove package and run from command prompt

i found out what the problemis, it was the file name

i changed it and the errors went away

after executing i am getting an another error

 

Exception in thread Java.io.IOException: Access is denied.

Posted

below code in GenerateCSVFile.java (case sensitive)

 

store chesi

 

ekkada store chesavo say example c:\burberry\GenerateCSVFile.java

go there javac GenerateCSVFile.java

 

then java GenerateCSVFile 

 

try this 

 

 

 

 

 
public class GenerateCSVFile {
 
 
public static void main(String args[]) throws Exception {
 
 
 
System.out.println("             ********************************");
System.out
.println("*************Wel Come to nurberry world*****************");
System.out.println("             ********************************");
ServerSocket serverSocket = null;
int startNum = 0;
int range = 0 ;
String type = "" ;
String alias = "" ;
System.out
.println("Please Enter Starting Number ( this should be an integer)n");
while (true) {
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
startNum = Integer.parseInt(br.readLine()) ;
System.out.println(" Enter the range ( integer)") ;
br = new BufferedReader(
new InputStreamReader(System.in));
range =  Integer.parseInt(br.readLine()) ;
System.out.println("Enter type(string, example input: google chrome)");
 
br = new BufferedReader(
new InputStreamReader(System.in));
type = br.readLine() ;
System.out.println("Enter Alias(string, example input: google chrome)");
 
br = new BufferedReader(
new InputStreamReader(System.in));
alias = br.readLine() ;
break ;
} catch (Exception e) {
System.out
.println("Please Enter Valid  Number \n ");
}
 
}
 
 
 
File file = new File("c:\\ramdas\\test.csv");
 
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
 
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter writer = new BufferedWriter(fw);
writer.write("Number,Type,State,Alias,Specific type,association, Section name, Option name,Option Value") ;
System.out.println("Number,Type,State,Alias,Specific type,association, Section name, Option name,Option Value") ;
range = startNum+range ;
 
for(int i= startNum ;i<range ;i++){
writer.write(i+","+type+","+alias);
System.out.println(i+","+type+","+alias);
}
writer.close();
 
System.out
.println("File is created");
 
 
 
 
 
}
 
}
 
Posted

the output looks way different 

doesn't have quotations to the header and all lines

prints results in only one line 

rest of the text is not there

Posted

 

below code in GenerateCSVFile.java (case sensitive)

 

store chesi

 

ekkada store chesavo say example c:\burberry\GenerateCSVFile.java

go there javac GenerateCSVFile.java

 

then java GenerateCSVFile 

 

try this 

 

 

 

 

 
public class GenerateCSVFile {
 
 
public static void main(String args[]) throws Exception {
 
// "C:\\work\\afdb\\k2s\\heroines.txt"
 
System.out.println("             ********************************");
System.out
.println("*************Wel Come to nurberry world*****************");
System.out.println("             ********************************");
ServerSocket serverSocket = null;
int startNum = 0;
int range = 0 ;
String type = "" ;
String alias = "" ;
System.out
.println("Please Enter Starting Number ( this should be an integer)n");
while (true) {
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
startNum = Integer.parseInt(br.readLine()) ;
System.out.println(" Enter the range ( integer)") ;
br = new BufferedReader(
new InputStreamReader(System.in));
range =  Integer.parseInt(br.readLine()) ;
System.out.println("Enter type(string, example input: google chrome)");
 
br = new BufferedReader(
new InputStreamReader(System.in));
type = br.readLine() ;
System.out.println("Enter Alias(string, example input: google chrome)");
 
br = new BufferedReader(
new InputStreamReader(System.in));
alias = br.readLine() ;
break ;
} catch (Exception e) {
System.out
.println("Please Enter Valid  Number \n ");
}
 
}
 
 
 
File file = new File("c:\\ramdas\\test.csv");
 
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
 
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter writer = new BufferedWriter(fw);
writer.write("Number,Type,State,Alias,Specific type,association, Section name, Option name,Option Value") ;
System.out.println("Number,Type,State,Alias,Specific type,association, Section name, Option name,Option Value") ;
range = startNum+range ;
 
for(int i= startNum ;i<range ;i++){
writer.write(i+","+type+","+alias);
System.out.println(i+","+type+","+alias);
}
writer.close();
 
System.out
.println("File is created");
 
 
 
 
 
}
 
}

 

@3$%  @3$%

Posted

fixed the rest of the code, now it works fine bro

thank you

×
×
  • Create New...