可能性の重複:
Java - Convert number to string次のコードでは、longデータ型をstringデータ型に変換することは可能ですか?
private String getHome() {
String defaultHome = Environment.getExternalStorageDirectory().getAbsolutePath();
File f = new File("/sdcard/download");
File[] files = f.listFiles();
for(int i=0; i < files.length; i++)
{
File file = files[i];
//take the file name only
long size = file.length()/1024;
String path = file.getPath().substring(file.getPath().lastIndexOf("/")+1,file.getPath().length()).toLowerCase();
String newString = size.toString();
//String path = getSharedPreferences(PREF_TAG, 0).getString(PREF_HOME,defaultHome);
//if (path.length()>1 && path.endsWith("/")) {
// path = path.substring(0,path.length()-2);
//}
//File pathFile = new File(path);
if (file.exists() && file.isDirectory())
return path+size;
else
return defaultHome+size;
}
return defaultHome;
}
まあのための参照を行うことができますような何かを行うことができますか何を試しましたか?それは動作しましたか?そうでない場合は、どうしてですか? –
http://stackoverflow.com/questions/2563608/check-whether-a-string-is-parsable-into-long-without-try-catch、http://stackoverflow.com/questions/4121923/-cant -convert-string-to-int、http://stackoverflow.com/questions/653990/what-is-the-most-efficient-way-to-convert-an-int-to-a-string、http: /stackoverflow.com/questions/5585779/converting-string-to-int-in-java、http://stackoverflow.com/questions/7604379/is-using-int-bad-for-converting-java-ints-to -strings –
関連する質問は「int」と関係がありますが、まったく同じことです*。投稿の99%は実際に質問に答える*無関係*であると考えてください。関連性のあるものだけを含める:*どのパートにコンバージョンが必要なのかわからない。 –