null « Development « Java I/O Q&A





1. nullobject for File in Java    stackoverflow.com

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 ...

2. while using g.drawImage(img,0,0,100,100,0,0,0,0,null) it does not produce any result?    stackoverflow.com

while using g.drawImage(img,0,0,100,100,0,0,0,0,null) it does not produce any result. So how to draw on the image in file of a better way?

3. Retrieving the underlying error when File.listFiles return null    stackoverflow.com

According to the File.listFiles javadoc the method

Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
I know that I ...

4. Deserialized object has null in all fields    stackoverflow.com

I have written my Container<T> class which backups its T items in several collections -- primary one is List<T>, others are various maps with data derived from items, mostly for optimized ...

5. How to serialize 'null' value?    stackoverflow.com

In our company we write a simple serializer/deserializer in Java. Does anybody know what is the best way to serialize a null value?

6. Can't get file name? Always null    stackoverflow.com

HTML

                        <form enctype="multipart/form-data" method="post" action="addCompany">
    ...

7. Java getClass().getResource("file") leads to NullPointerException    stackoverflow.com

ImageIcon iid = new ImageIcon(this.getClass().getResource("ball.png"));
ball = iid.getImage();
Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.(Unknown Source) at snake2.Board.(Board.java:52) ...

8. JAVA; When The string from the file is printed on screen null is also printed along with it at the end    stackoverflow.com

Soo my program is working...but there is just one problem...null is also being printed along with the content or string from the file... is there anyway i can stop null from ...

9. java object getClass() method returns null    stackoverflow.com

My understanding is if a java object xx is not null there must be corresponding Class object for that object that can get using getClass() method, but some time this method ...





10. Getting NULL value at the end while writing to the file    stackoverflow.com

I have problem while writing to the file. I want to write contents of my input file to output file but while writing to the file, I am getting NULL ...

11. form feed and null    coderanch.com

12. null and serialization    coderanch.com

Hi, I have a question on serialization: If an object say a String Object whose value is null is serialized. how will it be represented in the stream. If there are 2 Strings whose values are null and empty string.which one will give a better performance when serialized. {i.e.) does having a value as null gives good performance while serializing. Thanks ...

13. Externalizable and null values in read/writeExternal    coderanch.com

For performance purposes I chose to implement Externalizable but I am running into null pointer exceptions if any of my members are null. Originally, I wrote this helper: private static void checkAndWriteUTF (ObjectOutput out, String value) throws IOException { if (value != null) { out.writeBoolean (true); out.writeUTF (value); } else { out.writeBoolean (false); } } private static String checkAndReadUTF (ObjectInput in) ...

15. Class.getResourceAsStream() is returning null    coderanch.com

I am trying to read a text file as a resource using Class.getResourceAsStream(), but it is returning null. I've checked everything I can think of. Hopefully I can provide enough detail here so you can understand what I'm doing and point out where I'm going wrong. First of all, I have the following method that is supposed to read the text ...

16. any html file displays "null"    coderanch.com

Novice... I am using Tomcat 5.5. I tried servlet-examples. I tried to develop my first servlet and also developed html file to POST data on servlet. I renamed index.html which was there by default and put my index.html. Later,I thought that I shouldnt have done it, I renamed my index.html and put original index.html again. I restarted the server. But when ...





18. int[] = null; help    coderanch.com

Hi all. As normal how we declare a string array when we dont know the size i.e how much data should be inserted then i give as String[] str = null. After that i can perform all the operations. When i try to do the same with int that is int[] arr = null. I dont get compilation error, when i ...

19. Null SAXParser while creating getXmlReader() in Digeter class    coderanch.com

Hi All, I am trying to read an xml file and it gives me the following error : java.lang.NullPointerException at org.apache.commons.digester.Digester.getXMLReader(Digester.java:1058) at org.apache.commons.digester.Digester.parse(Digester.java:1887) at com.bof.BusinessObjectFactory.getInstance(BusinessObjectFactory.java:57) at com.servlets.MyProcessingServlet.doPost(MyProcessingServlet.java:46) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3504) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2186) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2092) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) When I checked the Digester ...

20. De-Serialization is returning Null values    coderanch.com

class TestStreams { public static void main(String args[]) { Collar a=new Collar("Red"); Collar b=new Collar("Blue"); Dog d1=new Dog(40,a); Dog d2=new Dog(50,b); //Serialize try{ FileOutputStream fos=new FileOutputStream("testSer.ser"); ObjectOutputStream oos=new ObjectOutputStream(fos); oos.writeObject(d1); //writeObject() argument is the object to be serialized oos.close(); }catch(Exception e){ e.printStackTrace(); } //de-serialize try{ FileInputStream fis=new FileInputStream("testSer.ser"); ObjectInputStream ois=new ObjectInputStream(fis); d1=(Dog) ois.readObject(); //readObject() argument nullgh }catch(Exception e){ e.printStackTrace(); } System.out.println("Weight ...

21. java.lang.IllegalArgumentException: im == null!    coderanch.com

ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write( new_img, "jpg", baos ); //baos.flush(); byte[] imageInByte = baos.toByteArray(); byte[] testByte=imageInByte; // //convert byte array back to BufferedImage System.out.println("Before Size"+imageInByte.length); byte[] output_data=steg_process(imageInByte, hidden_data); // System.out.println("After Size"+output_data.length); InputStream in = new ByteArrayInputStream(testByte);// I tried 'output_data' initially, // but as it did not work, then i put 'textByte' just for testing purpose System.out.println("Available: "+in.available()); img = ImageIO.read(in); ...

22. IOException returning null    coderanch.com

Hello All, My first Java post ever!!! I was hoping somebody could help me out with a school project i'm working on. We are learning data streams and I'm stuck at a certain point. I'm not sure why i'm receiving a null when I try to read the order.txt file. Can somebody maybe take a look at the code and point ...

23. Getting null when writing to file.    coderanch.com

Hiya fellas, So I have some code I'm doing for practice, I'm passing a String value called "charName" into the method setCharacterName(). Then writing it to a file, but when i check the file to see if the save was successful, it says "name null". Which leads be to believe some where down the line the Value is lost, but im ...

25. Size of serialized object with null values    java-forums.org

I want to create a serializable object with many different fields, but where, in any given object, only a few of those fields will have values. What I'm wondering is, when I write one of those objects to a file, will the file be a smaller size because only a few of the fields have values or will it be a ...

26. reading and writing to file , getting null when i try to read file content    forums.oracle.com

Definitely the wrong forum. But more importantly, there's way too much code in there. I'm not sure what your problem is but it would be much easier for somebody to look at one quarter of that code. So please toss out all the stuff which is irrelevant to your question -- that's probably 90% of the code -- and repost a ...

27. Output to file , file only shows null    forums.oracle.com

Then the array 'newBooks' only contains 'null' entries. My bet is that EITHER the array referenced by 'newBooks' that you are writing is not the same array you are filling OR you are a C++ programmer who thinks that declaring an array actually creates an array of objects and not just references to the objects each if which is initialized to ...

28. this.getClass().getResource(fileName); always returns null!     forums.oracle.com

I have spent hours looking through forum posts, trying various fixes, etc, but nothing works! When run from the compiler, the code is fine. When run from the JAR file, it gives me Null exception with ....(I'm "resourcing" a URL which I use to instantiate my ImageIcon, which I use to instantiate a JButton)...Now, the funny thing is, is that ...

29. File(String path) - i put a path but the object points to null...    forums.oracle.com

Ok so I have a bitmap image stored in the same folder as my java file. In the java file, I have the following code: File f = new File("test_image.bmp"); System.out.println(f.exists()); // output // false Where did I go wrong? What is the conventional way to specify the file path in java if the target file is 1) in the same ...

32. Inporting from file is coming up null    forums.oracle.com

I only get a blank space printed out Try changing the bit where you print the array elements so you can see exactly what robotApp contains: System.out.println(robotApp[k]); I don't use Scanner - but the docs say nextLine() advances the scanner past the current line and returns it (minus the terminator). This could leave room for problems if the file was generated ...