Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.task.task22.task2203;
- /*
- Между табуляциями
- */
- public class Solution {
- public static String getPartOfString(String string) throws TooShortStringException {
- if (string == null || string.isEmpty())
- {
- throw new TooShortStringException();
- }
- int indexOfFirstTab = string.indexOf("\t");
- if (indexOfFirstTab == -1)
- throw new TooShortStringException();
- int indexOfSecondTab = string.indexOf("\t", indexOfFirstTab + 1);
- if (indexOfSecondTab == -1)
- throw new TooShortStringException();
- return string.substring(indexOfFirstTab + 1, indexOfSecondTab);
- }
- public static class TooShortStringException extends Exception {
- public TooShortStringException() {
- super();
- }
- }
- public static void main(String[] args) throws TooShortStringException {
- System.out.println(getPartOfString("\tJavaRush - лучший сервис \tобучения Java\t."));
- }
- }
Add Comment
Please, Sign In to add comment