List of usage examples for java.lang System lineSeparator
String lineSeparator
To view the source code for java.lang System lineSeparator.
Click Source Link
From source file:com.example.amand.mobileprogrammingfitnessapp.LoggedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_logged); // toolbar reference, and is used to instantiate the toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitleTextColor(0xFFFFFFFF); setSupportActionBar(toolbar);// w ww . j a va 2 s .co m // this sets the toolbar colour and replaces the action bar, although this activity has style // of no actionbar // dialog is instantiated, and is set up with appropriate message, that is displayed when the user // presses the about icon dialog = new AlertDialog.Builder(this); dialog.setTitle("About"); dialog.setMessage("This appliation was developed for Mobile & Ubiquitous Computing. This application" + "is a fitness app and composed of contents, such as nutrition, health, exercises and gym facilities." + "The gym facilities provides numerous features, such as displaying gyms near you" + System.lineSeparator() + "The application makes use of a circular Imageview that under apache 2.0 Licencing" + "http://www.apache.org/licenses/LICENSE-2.0.txt"); // Reference to the database object, which is used to recieve users information database = new Database(getApplicationContext(), null, null, 1); // reference to the navogationn view that consists of navigation header and items navigationView = (NavigationView) findViewById(R.id.navigation_view); // the first fragment is loaded switchFragment(1); toolbar.setTitle("Nutrition"); // the references to textviews and circle imageview to change the details of the navigation drawer header = navigationView.getHeaderView(0); circle = (CircleImageView) header.findViewById(R.id.profile_image); namee = (TextView) header.findViewById(R.id.fullnameheader); username = (TextView) header.findViewById(R.id.usernameheader); naviagtionbackground = (RelativeLayout) header.findViewById(R.id.navbackground); // reference to the drawerlayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer); // reference to framelayout frame = (FrameLayout) findViewById(R.id.Screen); // the decode stream decode = new byte[100]; // this gets the information that is passed in from the register screen. The data is the username, and //is needed when using the database methods // if the data recieved is null, then the visabilty of the setting icon is false Intent intt = getIntent(); temp = intt.getStringExtra("key"); if (temp == null) { setting = false; } //Two methods are called, when the oncreate method has ran, the first method is responsible //in displaying the users detail in the navigation drawer, takes the username as parameters // Likewise the loadpreference method, loads the preference of each user setNavigationDetails(temp); loadpreferences(temp); // // database.loadPreferenes(temp); // objectDdecode = database.loadPreferenes(temp); // Toast.makeText(getApplicationContext(),"done" +database.loadPreferenes(temp).toString(),Toast.LENGTH_LONG).show(); // Toast.makeText(getApplicationContext(),objectDdecode.toString(),Toast.LENGTH_LONG).show(); // the naviagtion view is set with item click listener. This listens to the click of items that are // present in the application navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // this method is responosble for dealing with the menu items that have been clicked. public boolean onNavigationItemSelected(MenuItem menuItem) { // checks if the item has been selected, if its not selected set to false // else make it true to indicate its been checked if (menuItem.isChecked()) menuItem.setChecked(false); else menuItem.setChecked(true); //closes the naviagtion drawer once checked drawerLayout.closeDrawers(); //switch condidtion to assess what action is performed once the item has been checked switch (menuItem.getItemId()) { // the nutrition fragment is selected, if the gym icon is showing, it will disappear // the toolbar text is also set to nutrition case R.id.nutritionF: switchFragment(1); show = false; // reloads the option menu invalidateOptionsMenu(); toolbar.setTitle("Nutrition"); return true; // the health fragment is selected, if the gym icon is showing, it will disappear // the toolbar text is also set to Health case R.id.HealthF: switchFragment(3); toolbar.setTitle("Health"); show = false; // reloads the option menu invalidateOptionsMenu(); return true; // the exercie fragment is selected, if the gym icon is showing, it will disappear // the toolbar text is also set to Exercise case R.id.ExerciseF: Toast.makeText(getApplicationContext(), "Exercise", Toast.LENGTH_SHORT).show(); switchFragment(2); toolbar.setTitle("Exercises"); show = false; // reloads the option menu invalidateOptionsMenu(); return true; // the gym fragment is selected, if the gym icon is not showing, it will appear // the toolbar text is also set to gym case R.id.GymF: Toast.makeText(getApplicationContext(), "Gym Selected", Toast.LENGTH_SHORT).show(); switchFragment(4); toolbar.setTitle("Gym Facilities"); show = true; // reloads the option menu, to show the gym action icon invalidateOptionsMenu(); return true; // the logout item would just be intent back to the login screen. // to ensure user cannot travel back, the finish method is called to delete activity off the // stack case R.id.logoffF: Intent intt = new Intent(getApplicationContext(), LoginScreen.class); startActivity(intt); finish(); return true; // by default, even though this shouldnt happen, a toast message is presented to the user default: Toast.makeText(getApplicationContext(), "Somethings Wrong, please contact amandeep for more detail", Toast.LENGTH_SHORT).show(); return true; } } }); //Syncs the actionbartoggle to sync in with the toolbar new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.opendrawer, R.string.closedrawer) .syncState(); }
From source file:com.github.piotrkot.resources.CompilerResourceTest.java
/** * Appending logs should add them on the server. * @throws Exception If something fails. *//*from w ww . j a v a2s.com*/ @Test public void testAppendLogs() throws Exception { final String req = "log"; final String mesg = "message"; final String uri = String.format("http://localhost:%d/compiler/logs/0", CompilerResourceTest.APP_RULE.getLocalPort()); Assert.assertTrue(HTTP_RESP_OK.contains( Request.Delete(uri).setHeader(OK_AUTH).execute().returnResponse().getStatusLine().getStatusCode())); Assert.assertTrue(HTTP_RESP_OK .contains(Request.Post(uri).setHeader(OK_AUTH).bodyForm(Form.form().add(req, mesg).build()) .execute().returnResponse().getStatusLine().getStatusCode())); Assert.assertTrue(HTTP_RESP_OK .contains(Request.Post(uri).setHeader(OK_AUTH).bodyForm(Form.form().add(req, mesg).build()) .execute().returnResponse().getStatusLine().getStatusCode())); Assert.assertEquals(Joiner.on(System.lineSeparator()).join(mesg, mesg), Request.Get(uri).setHeader(OK_AUTH).execute().returnContent().asString()); }
From source file:ch.oakmountain.tpa.web.TpaWebPersistor.java
@Override public void addGraphLink(String source, String target, String category, String linkDescription, String sourceGroup, String targetGroup, String sourceGroupDescription, String targetGroupDescription) throws IOException { String line = "\"" + source + "\",\"" + target + "\",\"" + category + "\",\"" + linkDescription + "\",\"" + sourceGroup + "\",\"" + targetGroup + "\",\"" + sourceGroupDescription + "\",\"" + targetGroupDescription + "\"" + System.lineSeparator(); FileUtils.writeStringToFile(file, line, true); }
From source file:com.amazonaws.codepipeline.jenkinsplugin.ValidationTest.java
@Test public void validatePluginNoRegionFailure() { final String error = "AWS CodePipeline Jenkins plugin setup error. One or more required configuration parameters have not been specified." + System.lineSeparator(); final String regionError = "The specified AWS region is not valid."; thrown.expect(Failure.class); thrown.expectMessage(error);/*from w ww . j a v a 2 s . com*/ thrown.expectMessage(regionError); Validation.validatePlugin("", "", "", CategoryType.Build.getName(), "Jenkins-Build", "1", "ProjectName", null); }
From source file:org.apache.tomee.jul.handler.rotating.ArchivingTest.java
@Test public void logAndRotate() throws IOException, NoSuchMethodException { clean("target/ArchivingTest-" + format + "/logs"); final AtomicReference<String> today = new AtomicReference<>(); final Map<String, String> config = new HashMap<>(); // initial config today.set("2015-09-01"); config.put("filenamePattern", "target/ArchivingTest-" + format + "/logs/test.%s.%d.log"); config.put("archiveDirectory", "target/ArchivingTest-" + format + "/logs/archives"); config.put("archiveFormat", format); config.put("archiveOlderThan", "1 s"); config.put("limit", "10 kilobytes"); config.put("level", "INFO"); config.put("dateCheckInterval", "1 second"); final LocalFileHandler handler = new LocalFileHandler() { @Override/* w ww . j av a 2s . co m*/ protected String currentDate() { return today.get(); } @Override protected String getProperty(final String name, final String defaultValue) { final String s = config.get(name.substring(name.lastIndexOf('.') + 1)); return s != null ? s : defaultValue; } }; final String string10chars = "abcdefghij"; final int iterations = 950; for (int i = 0; i < iterations; i++) { handler.publish(new LogRecord(Level.INFO, string10chars)); } today.set("2015-09-02"); try { // ensure we test the date Thread.sleep(2000); } catch (final InterruptedException e) { Thread.interrupted(); } handler.publish(new LogRecord(Level.INFO, string10chars)); // will trigger the archiving handler.close(); withRetry(10, 3, new Runnable() { @Override public void run() { final File logGzip = new File( "target/ArchivingTest-" + format + "/logs/archives/test.2015-09-01.0.log." + format); assertTrue(logGzip.getAbsolutePath(), logGzip.isFile()); } }); // note: size depends on the date so just use a > min if ("gzip".equals(format)) { try (final GZIPInputStream gis = new GZIPInputStream( new FileInputStream("target/ArchivingTest-gzip/logs/archives/test.2015-09-01.0.log.gzip"))) { final String content = IOUtils.toString(gis); assertTrue( content.contains(Level.INFO.getLocalizedName() + ": abcdefghij" + System.lineSeparator())); assertTrue(content.length() > 10000); } } else { try (final ZipInputStream zis = new ZipInputStream( new FileInputStream("target/ArchivingTest-zip/logs/archives/test.2015-09-01.0.log.zip"))) { assertEquals("test.2015-09-01.0.log", zis.getNextEntry().getName()); final String content = IOUtils.toString(zis); assertTrue(content, content.contains(Level.INFO.getLocalizedName() + ": abcdefghij" + System.lineSeparator())); // INFO or INFOS assertTrue(content, content.length() > 10000); assertNull(zis.getNextEntry()); } } }
From source file:org.ballerinalang.composer.service.ballerina.launcher.service.LaunchManager.java
private void streamOutput() { try (InputStream inputStream = this.command.getProgram().getInputStream()) { while (this.command != null && this.command.getProgram().isAlive()) { String output = consumeStreamOutput(inputStream); if (!output.isEmpty()) { String[] lines = output.split(System.lineSeparator()); for (String line : lines) { // improve "server connector started" log message to have the service URL in it. // This is to handle the cloud use case. if (line.startsWith(LauncherConstants.SERVER_CONNECTOR_STARTED_AT_HTTP_CLOUD) && getServerStartedURL() != null) { this.updatePort(getServerStartedURL()); line = LauncherConstants.SERVER_CONNECTOR_STARTED_AT_HTTP_CLOUD + " " + getServerStartedURL(); }/*from w w w .ja v a 2 s.com*/ // This is to handle local service run use case. if (line.startsWith(LauncherConstants.SERVER_CONNECTOR_STARTED_AT_HTTP_LOCAL) && getServerStartedURL() == null) { // This is to handle local service run use case. this.updatePort(line); pushMessageToClient(launchSession, LauncherConstants.OUTPUT, LauncherConstants.DATA, line); } else { pushMessageToClient(launchSession, LauncherConstants.OUTPUT, LauncherConstants.DATA, line); } } } } pushMessageToClient(launchSession, LauncherConstants.EXECUTION_STOPPED, LauncherConstants.INFO, LauncherConstants.END_MESSAGE); LogParser.getLogParserInstance().stopListner(); } catch (IOException e) { logger.error("Error while sending output stream to client.", e); } }
From source file:com.consol.citrus.admin.process.listener.WebSocketProcessListener.java
@Override public void onProcessFail(String processId, Throwable e) { messagingTemplate.convertAndSend(TOPIC_LOG_OUTPUT, SocketEvent.createEvent(processId, SocketEvent.PROCESS_FAILED, "process failed with exception " + e.getLocalizedMessage() + System.lineSeparator())); }
From source file:com.bc.fiduceo.post.PostProcessingToolTest.java
@Test public void testPrintUsage() throws Exception { final ByteArrayOutputStream out = new ByteArrayOutputStream(); PostProcessingTool.printUsageTo(out); // PostProcessingTool.printUsageTo(System.out); final String ls = System.lineSeparator(); final String expected = "post-processing-tool version 1.2.1-SNAPSHOT" + ls + "" + ls + "usage: post-processing-tool <options>" + ls + "Valid options are:" + ls + " -c,--config <arg> Defines the configuration directory. Defaults to './config'." + ls + " -end,--end-date <arg> Defines the processing end-date, format 'yyyy-DDD'. DDD = Day of year." + ls + " -h,--help Prints the tool usage." + ls + " -i,--input-dir <arg> Defines the path to the input mmd files directory." + ls + " -j,--job-config <arg> Defines the path to post processing job configuration file. Path is relative to the" + ls + " configuration directory." + ls + " -start,--start-date <arg> Defines the processing start-date, format 'yyyy-DDD'. DDD = Day of year."; assertEquals(expected, out.toString().trim()); }
From source file:org.apache.ofbiz.base.start.StartupCommandUtil.java
static final void highlightAndPrintErrorMessage(String errorMessage) { System.err.println("===============================================================================" + System.lineSeparator() + errorMessage + System.lineSeparator() + "==============================================================================="); }
From source file:com.gargoylesoftware.htmlunit.runners.TestCaseCorrector.java
private static String getActualString(final ComparisonFailure failure) { String actual = failure.getActual(); actual = actual.substring(1, actual.length() - 1).replace("\r", "\\r").replace("\n", "\\n"); if (actual.length() > 96) { final StringBuilder builder = new StringBuilder(); while (!actual.isEmpty()) { int length = actual.lastIndexOf(',', 96) + 1; if (length == 0 && !actual.isEmpty()) { length = Math.min(96, actual.length()); }//w w w . j a va 2s .c o m if (builder.length() != 0) { builder.append(System.lineSeparator()).append(" + "); } builder.append('"').append(actual.substring(0, length)).append('"'); actual = actual.substring(length); } return builder.toString(); } return "\"" + actual + "\""; }