Is there any way to assign Array String to method java.lang.String.endwith(String suffix)


HOME ยป Java

I need to a file's suffix with an array list like

/>String[] FileType = {"pdf","mp3","jpg"}
File
SourceFileToCheckType = new File("C:UsersRSDesktop est.pdf"); />

using method below.... this method is full off
errors how to deal with such situation


public static
boolean FileTypeAccept(File SourceFileToCheckType, String[] fileType)

{
for (String filetypeS : fileType)

return SourceFileToCheckType.getName().endsWith("." +
filetypeS);
}

I need to a file's suffix with an array list like

/>String[] FileType = {"pdf","mp3","jpg"}
File
SourceFileToCheckType = new File("C:UsersRSDesktop est.pdf"); />

using method below.... this method is full off
errors how to deal with such situation


public static
boolean FileTypeAccept(File SourceFileToCheckType, String[] fileType)

{
for (String filetypeS : fileType)

return SourceFileToCheckType.getName().endsWith("." +
filetypeS);
}
Java

My DAO always throws this exception:
java.lang.NoSuchMethodError:
fr.la.juserright.metier.Ressource.<init>(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V

/>

RessourceDAO:


public List<Ressource>
readAll() throws SQLException {
List<Ressource>
__ressource = new ArrayList<Ressource>();

PreparedStatement _stmt = null;
ResultSet _rs = null;

try {
_stmt =
this.cnxUserRight.getCnx().prepareStatement(

"SELECT * FROM ressource");
_rs =
_stmt.executeQuery();
while (_rs.next()) {

Resso
Programming Languages

When executing mvn exec:java it fails to correctly
parse the configuration arguments, throwing the following
error:


[ERROR] Failed to execute goal

org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on

project autotest-programmes: Unable to parse configuration of mojo /> org.codehaus.mojo:exec-maven-plugin:1.2.1:java: Cannot assign /> configuration values to array of type java.lang.String:
[-classpath,
Classpath {}, --glue, com.company.test.cucumber,
--format, pretty,
--format, html:C:workspaceautotest arget] ->
[Help 1]


This is the plugin configuration used (using
Apach

Java

Can someone please HELP???

public
class Person { private String name; private String address;
private String phoneNumber; private String email; public
Person(){ } public Person(String name, String address, String
phoneNumber,String email) { this.name =name; this.address=address;
this.phoneNumber=phoneNumber; this.email=email; } public String
toString() { return "Person "+ this.getName(); } public String
getName(){ return name; }}class Student extends Person { private
static int FRESHMAN = 1; private static int SOPHOMORE = 2; private
static int JUNIOR = 3; private static int SENIOR = 4;
Development

The folowing program is the GAME OF THRONES-1 problem from
hackerrank. But I am facing the given error while executing.
I would be grateful if anyone could help.
The error would be:-
Exception in thread "main" java.lang.StringIndexOutOfBoundsException:
String index out of range: 5
at java.lang.String.charAt(String.java:646)



enter code here

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.Arrays;


public class try123 {

public static void main(String[] args) {
Scanner myScan = new Scanner(System.in);
String inputString = myScan.nextLine();
String s=inputString; //abccba
String ans; //YES or NO
String A="";
int flag=0;
String news="";
String nrev="";
String rev="";
//char arr[]=new char[100000];
char arr[]=inputString.toCharArray();
Arrays.sort(arr);
String b= new String(arr); //sorted string

int len=b.length();
if((len%2)!=0)
{ A=b.substring(len-1,len);

len=len-1;
b=b.substring(len-1);
flag=1;
}
for(int l=(len-1);l>=0;l--)
{
rev=rev+b.charAt(l);
}
for(int i=1;i<len;i=i+2) //len=6
{
news=news+b.charAt(i)+rev.charAt(i-1);
}
if(flag==1)
news=news.substring(0,(len/2)-1)+A+news.substring((len/2),len-1);
for(int o=(news.length()-1);o>=0;o--)
{
nrev=nrev+b.charAt(o);
}
if(news==nrev)
ans="YES";
else
ans="NO";
System.out.println(ans);
myScan.close();
}
}
Web Development

I am getting this error at runtime.




java.lang.RuntimeException: Unable to start activity
ComponentInfo
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a
null object reference




StackTrace:



01-12 03:44:54.270: E/AndroidRuntime(1437): FATAL
EXCEPTION: main
01-12 03:44:54.270: E/AndroidRuntime(1437): Process: home.saket, PID:
1437
01-12 03:44:54.270: E/AndroidRuntime(1437):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{home.saket/home.saket.addmember.Add_Update_User}:
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a
null object reference
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.ActivityThread.access$800(ActivityThread.java:144)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.os.Handler.dispatchMessage(Handler.java:102)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.os.Looper.loop(Looper.java:135)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.ActivityThread.main(ActivityThread.java:5221)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
java.lang.reflect.Method.invoke(Native Method)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
java.lang.reflect.Method.invoke(Method.java:372)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
01-12 03:44:54.270: E/AndroidRuntime(1437): Caused by:
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean java.lang.String.equalsIgnoreCase(java.lang.String)' on a
null object reference
01-12 03:44:54.270: E/AndroidRuntime(1437): at
home.saket.addmember.Add_Update_User.onCreate(Add_Update_User.java:38)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.Activity.performCreate(Activity.java:5933)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
01-12 03:44:54.270: E/AndroidRuntime(1437): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
01-12 03:44:54.270: E/AndroidRuntime(1437): ... 10 more
01-12 03:44:54.272: W/ActivityManager(472): Force finishing activity
home.saket/.addmember.Add_Update_User
01-12 03:44:54.273: E/ActivityManager(472): Invalid thumbnail
dimensions: 384x384


Below I am posted the codes and pointed out the error line.



Add_Update_User.java:



@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.add_update_screen);

// set screen
Set_Add_Update_Screen();

// set visibility of view as per calling activity
String called_from = getIntent().getStringExtra("called");

if (called_from.equalsIgnoreCase("add")) { --->38th error line
add_view.setVisibility(View.VISIBLE);
update_view.setVisibility(View.GONE);
} else {

update_view.setVisibility(View.VISIBLE);
add_view.setVisibility(View.GONE);
USER_ID =
Integer.parseInt(getIntent().getStringExtra("USER_ID"));

Contact c = dbHandler.Get_Contact(USER_ID);

add_name.setText(c.getName());
add_mobile.setText(c.getPhoneNumber());
add_email.setText(c.getEmail());
// dbHandler.close();
}
}
Web Development

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow