Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Deekhsha Kher

Greenhorn
+ Follow
since Jun 17, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Deekhsha Kher

Yes,using buffrered reader also the issue persists.

After analysis ,I found that the issue is with the UTF-8 encoding itself since whn we use some special characters like euro and pound some junk characers automatically get appended to it like a-with carat etc.After changing the encoding of the file to ISO-8859-1 I was able to upload the file sucessfully despite the file having the special characters.

Thankyou all for your time
9 years ago

If you look at the API of the read(char[] buf) method of the InputStreamReader class, you will see that we get -1 if we reach the end the stream (or the end of the file in our case).



This I know.But the point I am trying to make here is even though the read doesnot happen completely why are we getting res=-1?(See,if i remove the chracters D’MELLO ROAD,^TMUMBAI – from the UTF 8(Without BOM) file I am trying to upload then the data is being read properly by the InputStreamReader class but if I add this data the int being returned from the read method is -1. )

Another thing that I have noticed is ,if I put any character in UTF8 file which is having more than 1 byte value then only this res=-1 is coming.


The complete code goes like this:


The output of the code is-
1.res==-1 if i add all the above characters(total of 9 bytes).
2.res==7(8-1(additional byte)) if i add a 2 byte character in the file.
3.res==8 if i add only 1 byte chracters in the file.And the file is getting successfully uploaded.

The above code should not basically return false .This will happen only if SIZE_OF_FILETRAILER=res=8.

Please help.This is little urgent .
9 years ago
Hi,

I am having a UTF8 encoded file with the following characters data :

D’MELLO ROAD,^TMUMBAI – .

When I am trying to read from this file (to upload the same in the database)using the code below I am not able to do so successfully.


After this snippet the code logic is such that if variable res==-1 then the file upload should not be sucessfull.If I remove the above line from the code ,then using the same logic the file is getting uploaded successfully in database.
2 doubts I have-
1.Why are we checking res==-1 ?In what case will we get the value as -1.
2.How can I modify the code such that the above line is read properly?


9 years ago
Any websites in particular that might help with Java technical interviews...??eg careercup.com
9 years ago

arulk pillai wrote:I have blogged some questions and answers at 400+ Java Interview Questions and Answers

Also, try googling for: java interview questions


Thanks a lot
10 years ago

arulk pillai wrote:-- Brush on the core Java and enterprise Java fundamentals


any online material/books in particular ?
10 years ago

Bear Bibeault wrote:Firstly, please read KeepItDown and refrain from posting in all uppercase. I have adjusted the topic title for you.

Secondly, cramming for an interview is unlikely to help. You either know your stuff or you don't.





oops...i am sorry ...dint realize the caps....
And I am not asking where to cram from...wanted to know few titles that could had been helpful in brushing up my concepts...
10 years ago

Hi,

I am preparing for Java interview.I have 2 years of experience in Finacle(banking product of Infosys).Please suggest the material that will be needed to crack the technical interviews.Thanks in advance
10 years ago
I have the following directory structure:
My_Work\A.java

My_Work\C.java

My_Work\com\package1\A.class

A.java is as under:

package com.package1;

public class A{

public String impMethod(){

return "I am in important method";
}
public static void main(String args[]){

A objA=new A();

System.out.println("i am in class A");

System.out.println("Calling imp method---->"+objA.impMethod());
}
}
C.java is as under:

package com.package2;

import com.package1;

public class C{

public String impMethod(){

return "I am in important method";

}

public static void main(String args[]){

A objA=new A();

System.out.println("i am in class C");

System.out.println("Calling imp method---->"+objA.impMethod());

}

}

A.java compiles fine but when I try to compile C.java using D:\My_Work>javac C.java D:\My_Work>javac -d . C.java or I get the following compilation error:

C.java:3: cannot find symbol
symbol : class package1
location: package com
import com.package1;
^
C.java:10: cannot find symbol
symbol : class A
location: class com.package2.C
A objA=new A();
^
C.java:10: cannot find symbol
symbol : class A
location: class com.package2.C
A objA=new A();
^
3 errors

Please suggest some solution as I am not able to proceed with the basics