title: Deserialise a generic list in Gson
body: <p>I want to write a generic function which deserialise a generic type List with Gson
  here is the code:</p>
  
  <pre><code>private &lt;T&gt; List&lt;T&gt; GetListFromFile(String filename)
      {
          //Read textfile
          BufferedReader reader;
          String data="";
          try 
          {
              reader = new BufferedReader(new FileReader(filename));
              data = reader.readLine();
              reader.close();
          } 
          catch (FileNotFoundException ex) 
          {
  
          } 
          catch (IOException ex) 
          {
  
          }
          if (data == null) 
          {
              List&lt;T&gt; Spiel = new ArrayList&lt;T&gt;();
              return Spiel;
          }
          else
          {
              //get list with Deserialise
              Gson gson = new Gson();
              List&lt;T&gt; something = gson.fromJson(data, new TypeToken&lt;List&lt;T&gt;&gt;(){}.getType());
              return something;
          }
      }
  </code></pre>
  
  <p>But this code is not working, i get a strange structure but not a List of my type</p>
  
  <p>When i'am using:</p>
  
  <pre><code>List&lt;concreteType&gt; something = gson.fromJson(data, new TypeToken&lt;List&lt;T&gt;&gt;(){}.getType());
  </code></pre>
  
  <p>i works i get a <code>List&lt;concreteType&gt;</code>!!</p>
  
  <p>But i need a generic function, how can i fix it?</p>
  
  <p>Regards
  rubiktubik</p>