null

Parcel write/read doesn't work in AndroidTestCase -why?

陌路散爱 提交于 2019-12-24 09:20:37
问题 I am trying to test to write to a Parcel in Android test but it doesnt't work. s==null! What is wrong? public class scraptest extends AndroidTestCase { public void test() { Parcel parcel=Parcel.obtain(); parcel.writeString("sdfsdf"); String s=parcel.readString(); } } 回答1: One must reset the Parcel's data position with: parcel.setDataPosition(0); 来源: https://stackoverflow.com/questions/22832403/parcel-write-read-doesnt-work-in-androidtestcase-why

Java.NullPointerException null (again)

吃可爱长大的小学妹 提交于 2019-12-24 08:49:49
问题 I am having another problem with NullPointerException. This time it is highlighting tellen = telno.length() . Beore you ask: There is data in the text file to be read to that variable. All variables were initialized. Buffered Reader is also initialized. Here is a snippet of my code: while((telno = br.readLine()) != null){ name = br.readLine(); surname = br.readLine(); company = br.readLine(); house = br.readLine(); street = br.readLine(); locality = br.readLine(); postcode = br.readLine();

SQL Server Datetime NULL value

别等时光非礼了梦想. 提交于 2019-12-24 08:49:04
问题 I want to insert values into a SQL Server table, but every time I get "Cannot insert the value NULL into column 'ddod'" error. [ddod] [datetime] NOT NULL I'm not inserting NULL value, but 0000-00-00 00:00:00.000 , because no datetime was chosen. Is 0000-00-00 00:00:00.000 the same as NULL? Thanks a lot for help 回答1: '0000-00-00 00:00:00.000' is not a valid datetime select CAST('0000-00-00 00:00:00.000' as datetime) gives the following error The conversion of a varchar data type to a datetime

MySQL force query to return NULL

ε祈祈猫儿з 提交于 2019-12-24 08:34:20
问题 I have the following: SELECT q25, COUNT( q25 ) AS count, AVG (q1) AS q1 FROM tresults WHERE id = 'Yes' AND date = 'MARCH2010' AND q25 = '1' GROUP BY q25 At the moment, the query returns MySQL returned an empty result set (i.e. zero rows). which is correct - is it possible to get it to return NULL instead? OR Is there a way of dealing with this after the event in PHP, such as: $resultprev = mysql_query($queryprev); if($resultprev == ''){ // do something } 回答1: use mysql_num_rows : $resultprev

nullobject for File in Java

若如初见. 提交于 2019-12-24 08:00:09
问题 I have a class that occasionally gets passed null for File objects. During normal operation it uses a Scanner class to parse through the file. Instead of littering my code with null checks against the File objects, I thought I could replace the File s with nullobjects (Gang of Four style). However, it looks like File isn't really designed to be extended. Does any one have any pointers on how to do this? 回答1: You can replace the object that uses the file with a NullObject For instance, you can

Why Console in Eclipse or IntelliJ always null? [duplicate]

痞子三分冷 提交于 2019-12-24 07:59:32
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: System.Console() returns null Code: public class Demo { public static void main(String[] args){ Console c = System.console(); if (c == null) { System.err.println("No console."); System.exit(1); }else { System.out.println("Console is."); System.exit(0); } } } always No console. Why ? How to fix? Thanks. 回答1: You don't have any console associated. As per javadoc Returns the unique Console object associated with

Psycopg2 - How to include 'Null' values in inserting dictionary of list to table in postgres?

空扰寡人 提交于 2019-12-24 07:53:19
问题 I'm parsing my xml files and store them to a dictionary of list, where I will insert them into table at posgres using psycopg2. However, not all rows got inserted in the tables (it only inserted to the lowest number of values in the list). Here is the snippet of the dictionary of list: dict_songs = {'title' : ['Need You Now', 'GTFO'...], 'format': ['MP4', 'MP3'...], 'type' : ['Country Pop', 'R&B Pop'..], 'year': [2010,2018..]} dict_movie = {'title' : ['Searching', 'Sidewalk of New York'...],

Lua loadfile not finding a file

北慕城南 提交于 2019-12-24 07:39:17
问题 I had some lua code with the following line: JSON = loadfile("JSON.lua")() The file JSON.lua is in the same directory as the lua code that line came from. This code worked for me for a while, and then, without my changing either the lua source, or the JSON.lua, or permission of any of the files, or the directory from where I was running the lua code, I started getting a nil error on that line. (I simply recall NO relevant changes that could have any impact on the lua code.) Adding an assert

How to set the instance to null inside class?

房东的猫 提交于 2019-12-24 07:28:10
问题 I want to create a release() method in my class. After calling release() , how can I set that instance to null ? I mean this: ABC abc = new ABC(); abc.release(); if(abc == null) Log.d("That's what I want"); then I want to check if abc is null . How do I do this? 回答1: You don't have to do this from inside the instance per sé. If you remove the reference ( all references) to this object then it will be automatically removed the next time the garbage collector does his rounds. Simply do ABC abc

Loading an NSArray from a .plist file

人走茶凉 提交于 2019-12-24 07:19:23
问题 OK, so I know this question seems really basic, but I can't find a solution to my problem anywhere - I have a .plist file within my project entitled 'feelings'. My plist file reads: <plist version="1.0"> <dict> <key>feelings</key> <array> <string>Happy</string> <string>Sad</string> </array> </dict> </plist> In the .m file under -(void)ViewDidLoad; I am trying to retrieve the contents of the plist using the following code: NSString *path = [[NSBundle mainBundle] pathForResource:@"feelings"